java::io::InputStreamReader Class Reference

Inheritance diagram for java::io::InputStreamReader:

Inheritance graph
java::io::FileReaderjava::lang::Objectjava::lang::Interfacejava::io::Reader
[legend]
Collaboration diagram for java::io::InputStreamReader:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::io::Readerjava::lang::Comparable
[legend]

List of all members.


Detailed Description

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and translates them into characters according to a specified character encoding.

The encoding that it uses may be specified by name, or the platform's default encoding may be accepted.

Each invocation of one of an InputStreamReader's read() methods may cause one or more bytes to be read from the underlying byte-input stream. For top efficiency, consider wrapping an InputStreamReader within a BufferedReader; for example,

 BufferedReader in
   = new BufferedReader(new InputStreamReader(System.in));
 

Version:
1.13, 98/07/01
Author:
Mark Reinhold
Since:
JDK1.1

Public Member Functions

 InputStreamReader (const Ref< InputStream > &in=0, const String &enc=nilCString)
 Create an InputStreamReader that uses the named character encoding.
const String getEncoding () const
 Return the name of the encoding being used by this stream.
virtual jint read ()
 Read a single character.
virtual jint read (Array< jchar > &b, jint ofs=0, jint len=-1)
 Read characters into a portion of an array.
virtual jlong skip (jlong n)
 Skip characters.
virtual jboolean ready ()
 Tell whether this stream is ready to be read.
virtual void close ()
 Close the stream.

Constructor & Destructor Documentation

java::io::InputStreamReader::InputStreamReader ( const Ref< InputStream > &  in = 0,
const String enc = nilCString 
)

Create an InputStreamReader that uses the named character encoding.

Parameters:
in An InputStream
enc Name of encoding to be used
Exceptions:
UnsupportedEncodingException If the named encoding is not supported


Member Function Documentation

const String java::io::InputStreamReader::getEncoding (  )  const

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

May return null if the stream has been closed.

virtual jint java::io::InputStreamReader::read (  )  [virtual]

Read 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.

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
Exceptions:
IOException If an I/O error occurs

Implements java::io::Reader.

virtual jint java::io::InputStreamReader::read ( Array< jchar > &  b,
jint  ofs = 0,
jint  len = -1 
) [virtual]

Read characters into a portion of an array.

Parameters:
cbuf Destination buffer
off Offset at which to start storing characters
len Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Exceptions:
IOException If an I/O error occurs

Implements java::io::Reader.

virtual jlong java::io::InputStreamReader::skip ( jlong  n  )  [virtual]

Skip characters.

This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.

Parameters:
n The number of characters to skip
Returns:
The number of characters actually skipped
Exceptions:
IllegalArgumentException If n is negative.
IOException If an I/O error occurs

Implements java::io::Reader.

virtual jboolean java::io::InputStreamReader::ready (  )  [virtual]

Tell whether this stream is ready to be read.

An InputStreamReader is ready if its input buffer is not empty, or if bytes are available to be read from the underlying byte stream.

Exceptions:
IOException If an I/O error occurs

Reimplemented from java::io::Reader.

virtual void java::io::InputStreamReader::close (  )  [virtual]

Close the stream.

Exceptions:
IOException If an I/O error occurs

Reimplemented from java::io::Reader.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:32 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3