DthingApi
Public Member Functions | Static Public Member Functions | List of all members
java.io.DataInputStream Class Reference
Inheritance diagram for java.io.DataInputStream:
java.io.FilterInputStream java.io.DataInput java.io.InputStream jp.co.cmcc.event.EventInputStream

Public Member Functions

 DataInputStream (InputStream in)
 
int available () throws IOException
 
void close () throws IOException
 
synchronized void mark (int readlimit)
 
boolean markSupported ()
 
synchronized void reset () throws IOException
 
final int read (byte[] buffer) throws IOException
 
final int read (byte[] buffer, int offset, int length) throws IOException
 
final boolean readBoolean () throws IOException
 
final byte readByte () throws IOException
 
final char readChar () throws IOException
 
final double readDouble () throws IOException
 
final float readFloat () throws IOException
 
final void readFully (byte[] dst) throws IOException
 
final void readFully (byte[] dst, int offset, int byteCount) throws IOException
 
final int readInt () throws IOException
 
final long readLong () throws IOException
 
final short readShort () throws IOException
 
final int readUnsignedByte () throws IOException
 
final int readUnsignedShort () throws IOException
 
final String readUTF () throws IOException
 
long skip (long n) throws IOException
 
final int skipBytes (int count) throws IOException
 
- Public Member Functions inherited from java.io.FilterInputStream
 FilterInputStream (InputStream in)
 
int available () throws IOException
 
void close () throws IOException
 
synchronized void mark (int readlimit)
 
boolean markSupported ()
 
int read () throws IOException
 
int read (byte[] buffer, int offset, int count) throws IOException
 
synchronized void reset () throws IOException
 
long skip (long byteCount) throws IOException
 
- Public Member Functions inherited from java.io.InputStream
 InputStream ()
 
int available () throws IOException
 
void close () throws IOException
 
void mark (int readlimit)
 
boolean markSupported ()
 
abstract int read () throws IOException
 
int read (byte[] buffer) throws IOException
 
int read (byte[] buffer, int offset, int length) throws IOException
 
synchronized void reset () throws IOException
 
long skip (long byteCount) throws IOException
 

Static Public Member Functions

static final String readUTF (DataInput in) throws IOException
 

Additional Inherited Members

- Protected Attributes inherited from java.io.FilterInputStream
volatile InputStream in
 

Detailed Description

Wraps an existing InputStream and reads big-endian typed data from it. Typically, this stream has been written by a DataOutputStream. Types that can be read include byte, 16-bit short, 32-bit int, 32-bit float, 64-bit long, 64-bit double, byte strings, and strings encoded in modified UTF-8.

See also
DataOutputStream

Constructor & Destructor Documentation

◆ DataInputStream()

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

Constructs a new DataInputStream on the InputStream

. All reads are then filtered through this stream. Note that data read by this stream is not in a human readable format and was most likely created by a DataOutputStream.

Warning: passing a null source creates an invalid

. All operations on such a stream will fail.

Parameters
inthe source InputStream the filter reads from.
See also
DataOutputStream
RandomAccessFile

Member Function Documentation

◆ available()

int java.io.DataInputStream.available ( ) throws IOException
inline

Returns the number of bytes that can be read from this input stream without blocking.

This method simply performs in.available(n) and returns the result.

Returns
the number of bytes that can be read from the input stream without blocking.
Exceptions
IOExceptionif an I/O error occurs.

◆ close()

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

Closes this input stream and releases any system resources associated with the stream. This method simply performs in.close().

Exceptions
IOExceptionif an I/O error occurs.

◆ mark()

synchronized void java.io.DataInputStream.mark ( int  readlimit)
inline

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

This method simply performs in.mark(readlimit).

Parameters
readlimitthe maximum limit of bytes that can be read before the mark position becomes invalid.

◆ markSupported()

boolean java.io.DataInputStream.markSupported ( )
inline

Tests if this input stream supports the mark and reset methods. This method simply performs in.markSupported().

Returns
true if this stream type supports the mark and reset method; false otherwise.

◆ read()

final int java.io.DataInputStream.read ( byte []  buffer,
int  offset,
int  length 
) throws IOException
inline

Reads at most

length

bytes from this stream and stores them in the byte array

buffer

starting at

offset

. Returns the number of bytes that have been read or -1 if no bytes have been read and the end of the stream has been reached.

Parameters
bufferthe byte array in which to store the bytes read.
offsetthe initial position in
buffer
to store the bytes read from this stream.
lengththe maximum number of bytes to store in
buffer
.
Returns
the number of bytes that have been read or -1 if the end of the stream has been reached.
Exceptions
IOExceptionif a problem occurs while reading from this stream.
See also
DataOutput::write(byte[])
DataOutput::write(byte[], int, int)

◆ readBoolean()

final boolean java.io.DataInputStream.readBoolean ( ) throws IOException
inline

Reads a boolean.

Returns
the next boolean value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeBoolean(boolean)

Implements java.io.DataInput.

◆ readByte()

final byte java.io.DataInputStream.readByte ( ) throws IOException
inline

Reads an 8-bit byte value.

Returns
the next byte value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeByte(int)

Implements java.io.DataInput.

◆ readChar()

final char java.io.DataInputStream.readChar ( ) throws IOException
inline

Reads a big-endian 16-bit character value.

Returns
the next char value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeChar(int)

Implements java.io.DataInput.

◆ readDouble()

final double java.io.DataInputStream.readDouble ( ) throws IOException
inline

Reads a big-endian 64-bit double value.

Returns
the next double value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeDouble(double)

Implements java.io.DataInput.

◆ readFloat()

final float java.io.DataInputStream.readFloat ( ) throws IOException
inline

Reads a big-endian 32-bit float value.

Returns
the next float value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeFloat(float)

Implements java.io.DataInput.

◆ readFully() [1/2]

final void java.io.DataInputStream.readFully ( byte []  dst) throws IOException
inline

Equivalent to

readFully(dst, 0, dst.length);

.

Implements java.io.DataInput.

◆ readFully() [2/2]

final void java.io.DataInputStream.readFully ( byte []  dst,
int  offset,
int  byteCount 
) throws IOException
inline

Reads

byteCount

bytes from this stream and stores them in the byte array

dst

starting at

offset

. If

byteCount

is zero, then this method returns without reading any bytes. Otherwise, this method blocks until

byteCount

bytes have been read. If insufficient bytes are available,

EOFException

is thrown. If an I/O error occurs,

IOException

is thrown. When an exception is thrown, some bytes may have been consumed from the stream and written into the array.

Parameters
dstthe byte array into which the data is read.
offsetthe offset in
dst
at which to store the bytes.
byteCountthe number of bytes to read.
Exceptions
EOFExceptionif the end of the source stream is reached before enough bytes have been read.
IndexOutOfBoundsExceptionif
offset < 0
or
byteCount < 0
, or
offset + byteCount > dst.length
.
IOExceptionif a problem occurs while reading from this stream.
NullPointerExceptionif
dst
is null.

Implements java.io.DataInput.

◆ readInt()

final int java.io.DataInputStream.readInt ( ) throws IOException
inline

Reads a big-endian 32-bit integer value.

Returns
the next int value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeInt(int)

Implements java.io.DataInput.

◆ readLong()

final long java.io.DataInputStream.readLong ( ) throws IOException
inline

Reads a big-endian 64-bit long value.

Returns
the next long value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeLong(long)

Implements java.io.DataInput.

◆ readShort()

final short java.io.DataInputStream.readShort ( ) throws IOException
inline

Reads a big-endian 16-bit short value.

Returns
the next short value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeShort(int)

Implements java.io.DataInput.

◆ readUnsignedByte()

final int java.io.DataInputStream.readUnsignedByte ( ) throws IOException
inline

Reads an unsigned 8-bit byte value and returns it as an int.

Returns
the next unsigned byte value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeByte(int)

Implements java.io.DataInput.

◆ readUnsignedShort()

final int java.io.DataInputStream.readUnsignedShort ( ) throws IOException
inline

Reads a big-endian 16-bit unsigned short value and returns it as an int.

Returns
the next unsigned short value.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeShort(int)

Implements java.io.DataInput.

◆ readUTF()

final String java.io.DataInputStream.readUTF ( ) throws IOException
inline

Reads a string encoded with modified UTF-8.

Returns
the next string encoded with modified UTF-8.
Exceptions
EOFExceptionif the end of the input is reached before the read request can be satisfied.
IOExceptionif an I/O error occurs while reading.
See also
DataOutput::writeUTF(java.lang.String)

Implements java.io.DataInput.

◆ reset()

synchronized void java.io.DataInputStream.reset ( ) throws IOException
inline

Repositions this stream to the position at the time the mark method was last called on this input stream.

This method simply performs in.reset().

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Exceptions
IOExceptionif the stream has not been marked or if the mark has been invalidated.

◆ skip()

long java.io.DataInputStream.skip ( long  n) throws IOException
inline

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

This method simply performs in.skip(n).

Parameters
nthe number of bytes to be skipped.
Returns
the actual number of bytes skipped.
Exceptions
IOExceptionif an I/O error occurs.

◆ skipBytes()

final int java.io.DataInputStream.skipBytes ( int  count) throws IOException
inline

Skips

count

number of bytes in this stream. Subsequent

read()

s will not return these bytes unless

is used.

This method will not throw an EOFException if the end of the input is reached before

count

bytes where skipped.

Parameters
countthe number of bytes to skip.
Returns
the number of bytes actually skipped.
Exceptions
IOExceptionif a problem occurs during skipping.
See also
mark(int)
reset()

Implements java.io.DataInput.


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