java::io::DataInputStream Class Reference

Inheritance diagram for java::io::DataInputStream:

Inheritance graph
java::io::FilterInputStreamjava::lang::Objectjava::lang::Interfacejava::io::InputStreamjava::io::DataInput
[legend]
Collaboration diagram for java::io::DataInputStream:

Collaboration graph
java::io::FilterInputStreamjava::lang::Objectjava::lang::Interfacejava::io::InputStreamjava::io::DataInput
[legend]

List of all members.


Detailed Description

A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way.

An application uses a data output stream to write data that can later be read by a data input stream.

Data input streams and data output streams represent Unicode strings in a format that is a slight modification of UTF-8. (For more information, see X/Open Company Ltd., "File System Safe UCS Transformation Format (FSS_UTF)", X/Open Preliminary Specification, Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.)

All characters in the range '\u0001' to '\u007F' are represented by a single byte:

0 bits 0-7

The null character '\u0000' and characters in the range '\u0080' to '\u07FF' are represented by a pair of bytes:

1 1 0 bits 6-10
1 0 bits 0-5

Characters in the range '\u0800' to '\uFFFF' are represented by three bytes:
1 1 1 0 bits 12-15</td
1 0 bits 6-11
1 0 bits 0-5

The two differences between this format and the "standard" UTF-8 format are the following:

Author:
Arthur van Hoff
Version:
1.51, 02/28/00
See also:
java.io.DataOutputStream
Since:
JDK1.0

Public Member Functions

 DataInputStream (const Ref< InputStream > &in=0)
 Creates a FilterInputStream and saves its argument, the input stream in, for later use.
jint read ()
 Reads the next byte of data from the input stream.
jint read (Array< jbyte > &b, jint ofs=0, jint len=-1)
 See the general contract of the read method of DataInput.
jlong skip (jlong n)
 Skips over and discards n bytes of data from this input stream.

Constructor & Destructor Documentation

java::io::DataInputStream::DataInputStream ( const Ref< InputStream > &  in = 0  ) 

Creates a FilterInputStream and saves its argument, the input stream in, for later use.

An internal

Parameters:
in the input stream.


Member Function Documentation

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

Reads the next byte of data from the input stream.

The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

A subclass must provide an implementation of this method.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Exceptions:
IOException if an I/O error occurs.

Implements java::io::DataInput.

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

See the general contract of the read method of DataInput.

Bytes for this operation are read from the contained input stream.

Parameters:
b the buffer into which the data is read.
off the start offset of the data.
len the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Exceptions:
IOException if an I/O error occurs.

Implements java::io::DataInput.

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

Skips over and discards n bytes of data from this input stream.

The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

The skip method of InputStream creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.

Parameters:
n the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Exceptions:
IOException if an I/O error occurs.

Implements java::io::DataInput.


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