Class java.io.DataInputStream
All Packages Class Hierarchy This Package Previous Next Index
Class java.io.DataInputStream
java.lang.Object
|
+----java.io.InputStream
|
+----java.io.FilterInputStream
|
+----java.io.DataInputStream
- public class DataInputStream
- extends FilterInputStream
- implements DataInput
A data input stream that lets you read primitive Java data types
from a stream in a portable way. Primitive data types are well
understood types with associated operations. For example,
Integers are considered primitive data types.
- See Also:
- DataOutputStream
-
DataInputStream(InputStream)
- Creates a new DataInputStream.
-
read(byte[])
- Reads data into an array of bytes.
-
read(byte[], int, int)
- Reads data into an array of bytes.
-
readBoolean()
- Reads a boolean.
-
readByte()
- Reads an 8 bit byte.
-
readChar()
- Reads a 16 bit char.
-
readDouble()
- Reads a 64 bit double.
-
readFloat()
- Reads a 32 bit float.
-
readFully(byte[])
- Reads bytes, blocking until all bytes are read.
-
readFully(byte[], int, int)
- Reads bytes, blocking until all bytes are read.
-
readInt()
- Reads a 32 bit int.
-
readLine()
- Reads in a line that has been terminated by a \n, \r,
\r\n or EOF.
-
readLong()
- Reads a 64 bit long.
-
readShort()
- Reads a 16 bit short.
-
readUTF()
- Reads a UTF format String.
-
readUTF(DataInput)
- Reads a UTF format String from the given input stream.
-
readUnsignedByte()
- Reads an unsigned 8 bit byte.
-
readUnsignedShort()
- Reads 16 bit short.
-
skipBytes(int)
- Skips bytes, blocks until all bytes are skipped.
DataInputStream
public DataInputStream(InputStream in)
- Creates a new DataInputStream.
- Parameters:
- in - the input stream
read
public final int read(byte b[]) throws IOException
- Reads data into an array of bytes.
This method blocks until some input is available.
- Parameters:
- b - the buffer into which the data is read
- Returns:
- the actual number of bytes read, -1 is
returned when the end of the stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class FilterInputStream
read
public final int read(byte b[],
int off,
int len) throws IOException
- Reads data into an array of bytes.
This method blocks until some input is available.
- 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 actual number of bytes read, -1 is
returned when the end of the stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class FilterInputStream
readFully
public final void readFully(byte b[]) throws IOException
- Reads bytes, blocking until all bytes are read.
- Parameters:
- b - the buffer into which the data is read
- Throws: IOException
- If an I/O error has occurred.
- Throws: EOFException
- If EOF reached before all bytes are read.
readFully
public final void readFully(byte b[],
int off,
int len) throws IOException
- Reads bytes, blocking until all bytes are read.
- Parameters:
- b - the buffer into which the data is read
- off - the start offset of the data
- len - the maximum number of bytes read
- Throws: IOException
- If an I/O error has occurred.
- Throws: EOFException
- If EOF reached before all bytes are read.
skipBytes
public final int skipBytes(int n) throws IOException
- Skips bytes, blocks until all bytes are skipped.
- Parameters:
- n - the number of bytes to be skipped
- Returns:
- the actual number of bytes skipped.
- Throws: IOException
- If an I/O error has occurred.
readBoolean
public final boolean readBoolean() throws IOException
- Reads a boolean.
- Returns:
- the boolean read.
readByte
public final byte readByte() throws IOException
- Reads an 8 bit byte.
- Returns:
- the 8 bit byte read.
readUnsignedByte
public final int readUnsignedByte() throws IOException
- Reads an unsigned 8 bit byte.
- Returns:
- the 8 bit byte read.
readShort
public final short readShort() throws IOException
- Reads a 16 bit short.
- Returns:
- the 16 bit short read.
readUnsignedShort
public final int readUnsignedShort() throws IOException
- Reads 16 bit short.
- Returns:
- the 16 bit short read.
readChar
public final char readChar() throws IOException
- Reads a 16 bit char.
- Returns:
- the read 16 bit char.
readInt
public final int readInt() throws IOException
- Reads a 32 bit int.
- Returns:
- the 32 bit integer read.
readLong
public final long readLong() throws IOException
- Reads a 64 bit long.
- Returns:
- the 64 bit long read.
readFloat
public final float readFloat() throws IOException
- Reads a 32 bit float.
- Returns:
- the read 32 bit float.
readDouble
public final double readDouble() throws IOException
- Reads a 64 bit double.
- Returns:
- the 64 bit double read.
readLine
public final String readLine() throws IOException
- Reads in a line that has been terminated by a \n, \r,
\r\n or EOF.
- Returns:
- a String copy of the line.
readUTF
public final String readUTF() throws IOException
- Reads a UTF format String.
- Returns:
- the String.
readUTF
public final static String readUTF(DataInput in) throws IOException
- Reads a UTF format String from the given input stream.
- Returns:
- the String.
All Packages Class Hierarchy This Package Previous Next Index