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

Constructor Index

 o DataInputStream(InputStream)
Creates a new DataInputStream.

Method Index

 o read(byte[])
Reads data into an array of bytes.
 o read(byte[], int, int)
Reads data into an array of bytes.
 o readBoolean()
Reads in a boolean.
 o readByte()
Reads an 8 bit byte.
 o readChar()
Reads a 16 bit char.
 o readDouble()
Reads a 64 bit double.
 o readFloat()
Reads a 32 bit float.
 o readFully(byte[])
Reads bytes, blocking until all bytes are read.
 o readFully(byte[], int, int)
Reads bytes, blocking until all bytes are read.
 o readInt()
Reads a 32 bit int.
 o readLine()
Reads in a line that has been terminated by a \n, \r, \r\n or EOF.
 o readLong()
Reads a 64 bit long.
 o readShort()
Reads 16 bit short.
 o readUTF()
Reads a UTF format String.
 o readUTF(DataInput)
Reads a UTF format String from the given input stream.
 o readUnsignedByte()
Reads an unsigned 8 bit byte.
 o readUnsignedShort()
Reads 16 bit short.
 o skipBytes(int)
Skips bytes, block until all bytes are skipped.

Constructors

 o DataInputStream
  public DataInputStream(InputStream in)
Creates a new DataInputStream.
Parameters:
in - the input stream

Methods

 o 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
 o 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
 o 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.
 o 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.
 o skipBytes
  public final int skipBytes(int n) throws IOException
Skips bytes, block 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.
 o readBoolean
  public final boolean readBoolean() throws IOException
Reads in a boolean.
Returns:
the boolean read.
 o readByte
  public final byte readByte() throws IOException
Reads an 8 bit byte.
Returns:
the 8 bit byte read.
 o readUnsignedByte
  public final int readUnsignedByte() throws IOException
Reads an unsigned 8 bit byte.
Returns:
the 8 bit byte read.
 o readShort
  public final short readShort() throws IOException
Reads 16 bit short.
Returns:
the read 16 bit short.
 o readUnsignedShort
  public final int readUnsignedShort() throws IOException
Reads 16 bit short.
Returns:
the read 16 bit short.
 o readChar
  public final char readChar() throws IOException
Reads a 16 bit char.
Returns:
the read 16 bit char.
 o readInt
  public final int readInt() throws IOException
Reads a 32 bit int.
Returns:
the read 32 bit integer.
 o readLong
  public final long readLong() throws IOException
Reads a 64 bit long.
Returns:
the read 64 bit long.
 o readFloat
  public final float readFloat() throws IOException
Reads a 32 bit float.
Returns:
the read 32 bit float.
 o readDouble
  public final double readDouble() throws IOException
Reads a 64 bit double.
Returns:
the read 64 bit double.
 o 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.
 o readUTF
  public final String readUTF() throws IOException
Reads a UTF format String.
Returns:
the String.
 o 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