java.io.DataInput
DataInput is an interface which declares methods for reading in typed data
from a Stream. Typically, this stream has been written by a class which
implements DataOutput. 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 UTF
Strings.
Known Indirect Subclasses
| DataInputStream |
DataInputStream is a filter class which can read typed data from a Stream. |
| ObjectInput |
Streams to be used with serialization to read objects must implement this
interface. |
| ObjectInputStream |
An ObjectInputStream can be used to load Java objects from a stream where the
objects were saved using an ObjectOutputStream. |
| RandomAccessFile |
RandomAccessFile is a class which allows positioning of the next read
anywhere in the file. |
Summary
Details
Public Methods
public
boolean
readBoolean()
Reads a boolean from this stream.
Returns
- the next boolean value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
byte
readByte()
Reads an 8-bit byte value from this stream.
Returns
- the next byte value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
char
readChar()
Reads a 16-bit character value from this stream.
Returns
- the next
char value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
double
readDouble()
Reads a 64-bit
double value from this stream.
Returns
- the next
double value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
float
readFloat()
Reads a 32-bit
float value from this stream.
Returns
- the next
float value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
void
readFully(byte[] buffer, int offset, int count)
Read bytes from this stream and stores them in byte array
buffer starting at offset
offset. This
method blocks until
count number of bytes have been read.
Parameters
| buffer
| the byte array in which to store the read bytes. |
| offset
| the offset in buffer to store the read bytes. |
| count
| the maximum number of bytes to store in buffer. |
Throws
| IOException
| If a problem occurs reading from this stream. |
public
void
readFully(byte[] buffer)
Reads bytes from this stream into the byte array
buffer.
This method will block until
buffer.length number of bytes
have been read.
Parameters
| buffer
| the buffer to read bytes into |
Throws
| IOException
| If a problem occurs reading from this stream. |
public
int
readInt()
Reads a 32-bit integer value from this stream.
Returns
- the next
int value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
String
readLine()
Answers a
String representing the next line of text
available in this BufferedReader. A line is represented by 0 or more
characters followed by
'\n',
'\r',
"\n\r" or end of stream. The
String does
not include the newline sequence.
Returns
- the contents of the line or null if no characters were read
before end of stream.
Throws
| IOException
| If a problem occurs reading from this stream.
|
public
long
readLong()
Reads a 64-bit
long value from this stream.
Returns
- the next
long value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
short
readShort()
Reads a 16-bit
short value from this stream.
Returns
- the next
short value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
String
readUTF()
Reads a UTF format String from this Stream.
Returns
- the next UTF String from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
int
readUnsignedByte()
Reads an unsigned 8-bit
byte value from this stream and
returns it as an int.
Returns
- the next unsigned byte value from the source stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
int
readUnsignedShort()
Reads a 16-bit unsigned
short value from this stream and
returns it as an int.
Returns
- the next unsigned
short value from the source
stream.
Throws
| IOException
| If a problem occurs reading from this stream. |
public
int
skipBytes(int count)
Skips
count number of bytes in this stream. Subsequent
read()'s will not return these bytes unless
reset() is used.
Parameters
| count
| the number of bytes to skip. |
Returns
- the number of bytes actually skipped.
Throws
| IOException
| If a problem occurs reading from this stream.
|