|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.io.DataInputStream
public class DataInputStream
DataInputStream is a filter class which can read typed data from a Stream. 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 UTF Strings.
DataOutputStream| Field Summary |
|---|
| Fields inherited from class java.io.FilterInputStream |
|---|
in |
| Constructor Summary | |
|---|---|
DataInputStream(InputStream in)
Constructs a new DataInputStream on the InputStream in. |
|
| Method Summary | |
|---|---|
(package private) String |
decodeUTF(int utfSize)
|
int |
read(byte[] buffer)
Reads bytes from the source stream into the byte array buffer. |
int |
read(byte[] buffer,
int offset,
int length)
Read at most length bytes from this DataInputStream and
stores them in byte array buffer starting at
offset. |
boolean |
readBoolean()
Reads a boolean from this stream. |
byte |
readByte()
Reads an 8-bit byte value from this stream. |
char |
readChar()
Reads a 16-bit character value from this stream. |
double |
readDouble()
Reads a 64-bit double value from this stream. |
float |
readFloat()
Reads a 32-bit float value from this stream. |
void |
readFully(byte[] buffer)
Reads bytes from this stream into the byte array buffer. |
void |
readFully(byte[] buffer,
int offset,
int length)
Reads bytes from this stream and stores them in the byte array buffer starting at the position offset. |
int |
readInt()
Reads a 32-bit integer value from this stream. |
String |
readLine()
Deprecated. Use BufferedReader |
long |
readLong()
Reads a 64-bit long value from this stream. |
short |
readShort()
Reads a 16-bit short value from this stream. |
int |
readUnsignedByte()
Reads an unsigned 8-bit byte value from this stream and
returns it as an int. |
int |
readUnsignedShort()
Reads a 16-bit unsigned short value from this stream and
returns it as an int. |
String |
readUTF()
Reads a UTF format String from this Stream. |
static String |
readUTF(DataInput in)
Reads a UTF format String from the DataInput Stream in. |
int |
skipBytes(int count)
Skips count number of bytes in this stream. |
| Methods inherited from class java.io.FilterInputStream |
|---|
available, close, mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DataInputStream(InputStream in)
in.
All reads can now be 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.
in - the target InputStream to filter reads on.DataOutputStream,
RandomAccessFile| Method Detail |
|---|
public final int read(byte[] buffer)
throws IOException
buffer. The number of bytes actually read is returned.
read in class FilterInputStreambuffer - the buffer to read bytes into
IOException - If a problem occurs reading from this DataInputStream.DataOutput.write(byte[]),
DataOutput.write(byte[], int, int)
public final int read(byte[] buffer,
int offset,
int length)
throws IOException
length bytes from this DataInputStream and
stores them in byte array buffer starting at
offset. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
read in class FilterInputStreambuffer - the byte array in which to store the read bytes.offset - the offset in buffer to store the read bytes.length - the maximum number of bytes to store in buffer.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.write(byte[]),
DataOutput.write(byte[], int, int)
public final boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOException - If a problem occurs reading from this DataInputStream.DataOutput.writeBoolean(boolean)
public final byte readByte()
throws IOException
readByte in interface DataInputIOException - If a problem occurs reading from this DataInputStream.DataOutput.writeByte(int)
public final char readChar()
throws IOException
readChar in interface DataInputchar value from the source stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeChar(int)
public final double readDouble()
throws IOException
double value from this stream.
readDouble in interface DataInputdouble value from the source stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeDouble(double)
public final float readFloat()
throws IOException
float value from this stream.
readFloat in interface DataInputfloat value from the source stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeFloat(float)
public final void readFully(byte[] buffer)
throws IOException
buffer.
This method will block until buffer.length number of bytes
have been read.
readFully in interface DataInputbuffer - to read bytes into
IOException - If a problem occurs reading from this DataInputStream.DataOutput.write(byte[]),
DataOutput.write(byte[], int, int)
public final void readFully(byte[] buffer,
int offset,
int length)
throws IOException
buffer starting at the position offset.
This method blocks until count bytes have been read.
readFully in interface DataInputbuffer - the byte array into which the data is readoffset - the offset the operation start atlength - the maximum number of bytes to read
IOException - if a problem occurs while reading from this stream
EOFException - if reaches the end of the stream before enough bytes have
been readDataInput.readFully(byte[], int, int)
public final int readInt()
throws IOException
readInt in interface DataInputint value from the source stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeInt(int)
@Deprecated
public final String readLine()
throws IOException
BufferedReader
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.
readLine in interface DataInputIOException - If the DataInputStream is already closed or some other IO
error occurs.
public final long readLong()
throws IOException
long value from this stream.
readLong in interface DataInputlong value from the source stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeLong(long)
public final short readShort()
throws IOException
short value from this stream.
readShort in interface DataInputshort value from the source stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeShort(int)
public final int readUnsignedByte()
throws IOException
byte value from this stream and
returns it as an int.
readUnsignedByte in interface DataInputIOException - If a problem occurs reading from this DataInputStream.DataOutput.writeByte(int)
public final int readUnsignedShort()
throws IOException
short value from this stream and
returns it as an int.
readUnsignedShort in interface DataInputshort value from the source
stream.
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeShort(int)
public final String readUTF()
throws IOException
readUTF in interface DataInputIOException - If a problem occurs reading from this DataInputStream.DataOutput.writeUTF(java.lang.String)
String decodeUTF(int utfSize)
throws IOException
IOException
public static final String readUTF(DataInput in)
throws IOException
in.
in - the input stream to read from
IOException - If a problem occurs reading from this DataInputStream.DataOutput.writeUTF(java.lang.String)
public final int skipBytes(int count)
throws IOException
count number of bytes in this stream. Subsequent
read()'s will not return these bytes unless
reset() is used.
skipBytes in interface DataInputcount - the number of bytes to skip.
IOException - If the stream is already closed or another IOException
occurs.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||