public class

StreamDecoder

extends Reader
java.lang.Object
   ↳ java.io.Reader
     ↳ sun.nio.cs.StreamDecoder

Summary

[Expand]
Inherited Fields
From class java.io.Reader
Public Methods
void close()
Closes the stream and releases any system resources associated with it.
static StreamDecoder forDecoder(ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)
static StreamDecoder forInputStreamReader(InputStream in, Object lock, String charsetName)
static StreamDecoder forInputStreamReader(InputStream in, Object lock, Charset cs)
static StreamDecoder forInputStreamReader(InputStream in, Object lock, CharsetDecoder dec)
String getEncoding()
int read()
Reads a single character.
int read(char[] cbuf, int offset, int length)
Reads characters into a portion of an array.
boolean ready()
Tells whether this stream is ready to be read.
[Expand]
Inherited Methods
From class java.io.Reader
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.Readable

Public Methods

public void 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.

Throws
IOException

public static StreamDecoder forDecoder (ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)

public static StreamDecoder forInputStreamReader (InputStream in, Object lock, String charsetName)

public static StreamDecoder forInputStreamReader (InputStream in, Object lock, Charset cs)

public static StreamDecoder forInputStreamReader (InputStream in, Object lock, CharsetDecoder dec)

public String getEncoding ()

public int read ()

Reads a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Subclasses that intend to support efficient single-character input should override this method.

Returns
  • The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
Throws
IOException

public int read (char[] cbuf, int offset, int length)

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.

Parameters
cbuf Destination buffer
offset Offset at which to start storing characters
length Maximum number of characters to read
Returns
  • The number of characters read, or -1 if the end of the stream has been reached
Throws
IOException

public boolean ready ()

Tells whether this stream is ready to be read.

Returns
  • True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
Throws
IOException