Top Description Fields Constructors Methods
org.yaml.snakeyaml.reader

public Class UnicodeReader

extends Reader
Class Inheritance
Imports
java.io.IOException, .InputStream, .InputStreamReader, .PushbackInputStream, .Reader, java.nio.charset.Charset, .CharsetDecoder, .CodingErrorAction, .StandardCharsets

Generic unicode textreader, which will use BOM mark to identify the encoding to be used. If BOM is not found then use a given default or system encoding.

Field Summary

Modifier and TypeField and Description
private static final int
pack-priv PushbackInputStream
pack-priv InputStreamReader
private static final Charset
private static final Charset
private static final Charset
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
public
UnicodeReader(InputStream
InputStream to be read
in
)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.
public String

Returns:

the name of the character encoding being used by this stream.
getEncoding
()

Get stream encoding or NULL if stream is uninitialized.

protected void
init()

Read-ahead four bytes and check for BOM marks.

public int
read(char[]
Destination buffer
cbuf
,
int
Offset at which to start storing characters
off
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.
Inherited from java.io.Reader:
markmarkSupportednullReaderreadreadreadreadyresetskiptransferTo

Field Detail

BOM_SIZEback to summary
private static final int BOM_SIZE
internalInback to summary
pack-priv PushbackInputStream internalIn
internalIn2back to summary
pack-priv InputStreamReader internalIn2
UTF16BEback to summary
private static final Charset UTF16BE
UTF16LEback to summary
private static final Charset UTF16LE
UTF8back to summary
private static final Charset UTF8

Constructor Detail

UnicodeReaderback to summary
public UnicodeReader(InputStream in)
Parameters
in:InputStream

InputStream to be read

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Exceptions
IOException:
If an I/O error occurs
getEncodingback to summary
public String getEncoding()

Get stream encoding or NULL if stream is uninitialized. Call init() or read() method to initialize it.

Returns:String

the name of the character encoding being used by this stream.

initback to summary
protected void init() throws IOException

Read-ahead four bytes and check for BOM marks. Extra bytes are unread back to the stream, only BOM bytes are skipped.

Exceptions
IOException:
if InputStream cannot be created
readback to summary
public int read(char[] cbuf, int off, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
cbuf:char[]

Destination buffer

off:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs