DthingApi
Public Member Functions | List of all members
java.io.InputStreamReader Class Reference
Inheritance diagram for java.io.InputStreamReader:
java.io.Reader

Public Member Functions

 InputStreamReader (InputStream in)
 
 InputStreamReader (InputStream in, final String enc) throws UnsupportedEncodingException
 
void close () throws IOException
 
String getEncoding ()
 
int read () throws IOException
 
int read (char[] buffer, int offset, int length) throws IOException
 
boolean ready () throws IOException
 
void mark (int readLimit) throws IOException
 
boolean markSupported ()
 
void reset () throws IOException
 
- Public Member Functions inherited from java.io.Reader
abstract void close () throws IOException
 
void mark (int readLimit) throws IOException
 
boolean markSupported ()
 
int read () throws IOException
 
int read (char[] buf) throws IOException
 
abstract int read (char[] buf, int offset, int count) throws IOException
 
boolean ready () throws IOException
 
void reset () throws IOException
 
long skip (long charCount) throws IOException
 

Additional Inherited Members

- Protected Member Functions inherited from java.io.Reader
 Reader ()
 
 Reader (Object lock)
 
- Protected Attributes inherited from java.io.Reader
Object lock
 

Detailed Description

A class for turning a byte stream into a character stream. Data read from the source input stream is converted into characters by either a default or a provided character converter. The default encoding is taken from the "file.encoding" system property.

contains a buffer of bytes read from the source stream and converts these into characters as needed. The buffer size is 8K.

See also
OutputStreamWriter

Constructor & Destructor Documentation

◆ InputStreamReader() [1/2]

java.io.InputStreamReader.InputStreamReader ( InputStream  in)
inline

Constructs a new

on the InputStream

in

. This constructor sets the character converter to the encoding specified in the "file.encoding" property and falls back to ISO 8859_1 (ISO-Latin-1) if the property doesn't exist.

Parameters
inthe input stream from which to read characters.

◆ InputStreamReader() [2/2]

java.io.InputStreamReader.InputStreamReader ( InputStream  in,
final String  enc 
) throws UnsupportedEncodingException
inline

Constructs a new InputStreamReader on the InputStream

in

. The character converter that is used to decode bytes into characters is identified by name by

enc

. If the encoding cannot be found, an UnsupportedEncodingException error is thrown.

Parameters
inthe InputStream from which to read characters.
encidentifies the character converter to use.
Exceptions
NullPointerExceptionif
enc
is
null
.
UnsupportedEncodingExceptionif the encoding specified by
enc
cannot be found.

Member Function Documentation

◆ close()

void java.io.InputStreamReader.close ( ) throws IOException
inline

Closes this reader. This implementation closes the source InputStream and releases all local storage.

Exceptions
IOExceptionif an error occurs attempting to close this reader.

◆ getEncoding()

String java.io.InputStreamReader.getEncoding ( )
inline

Returns the historical name of the encoding used by this writer to convert characters to bytes, or null if this writer has been closed. Most callers should probably keep track of the String or Charset they passed in; this method may not return the same name.

◆ mark()

void java.io.InputStreamReader.mark ( int  readLimit) throws IOException
inline

Sets a mark position in this reader. The parameter

readLimit

indicates how many characters can be read before the mark is invalidated. Calling

will reposition the reader back to the marked position if

readLimit

has not been surpassed.

This default implementation simply throws an

IOException

; subclasses must provide their own implementation.

Parameters
readLimitthe number of characters that can be read before the mark is invalidated.
Exceptions
IllegalArgumentExceptionif
readLimit < 0
.
IOExceptionif an error occurs while setting a mark in this reader.
See also
markSupported()
reset()

◆ markSupported()

boolean java.io.InputStreamReader.markSupported ( )
inline

Indicates whether this reader supports the

mark()

and

methods. This default implementation returns

false

.

Returns
always
false
.

◆ read() [1/2]

int java.io.InputStreamReader.read ( ) throws IOException
inline

Reads a single character from this reader and returns it as an integer with the two higher-order bytes set to 0. Returns -1 if the end of the reader has been reached. The byte value is either obtained from converting bytes in this reader's buffer or by first filling the buffer from the source InputStream and then reading from the buffer.

Returns
the character read or -1 if the end of the reader has been reached.
Exceptions
IOExceptionif this reader is closed or some other I/O error occurs.

◆ read() [2/2]

int java.io.InputStreamReader.read ( char []  buffer,
int  offset,
int  length 
) throws IOException
inline

Reads at most

length

characters from this reader and stores them at position

offset

in the character array

buf

. Returns the number of characters actually read or -1 if the end of the reader has been reached. The bytes are either obtained from converting bytes in this reader's buffer or by first filling the buffer from the source InputStream and then reading from the buffer.

Parameters
bufferthe array to store the characters read.
offsetthe initial position in
buf
to store the characters read from this reader.
lengththe maximum number of characters to read.
Returns
the number of characters read or -1 if the end of the reader has been reached.
Exceptions
IndexOutOfBoundsExceptionif
offset < 0
or
length < 0
, or if
offset + length
is greater than the length of
buf
.
IOExceptionif this reader is closed or some other I/O error occurs.

◆ ready()

boolean java.io.InputStreamReader.ready ( ) throws IOException
inline

Indicates whether this reader is ready to be read without blocking. If the result is

true

, the next

read()

will not block. If the result is

false

then this reader may or may not block when

read()

is called. This implementation returns

true

if there are bytes available in the buffer or the source stream has bytes available.

Returns
true
if the receiver will not block when
read()
is called,
false
if unknown or blocking will occur.
Exceptions
IOExceptionif this reader is closed or some other I/O error occurs.

◆ reset()

void java.io.InputStreamReader.reset ( ) throws IOException
inline

Resets this reader's position to the last

mark()

location. Invocations of

read()

and

skip()

will occur from this new location. If this reader has not been marked, the behavior of

is implementation specific. This default implementation throws an

IOException

.

Exceptions
IOExceptionalways thrown in this default implementation.
See also
mark(int)
markSupported()

The documentation for this class was generated from the following file: