jcontrol.io
Class DataInputStream

java.lang.Object
  extended by jcontrol.io.InputStream
      extended by jcontrol.io.DataInputStream
Direct Known Subclasses:
GenericDataInputStream

public abstract class DataInputStream
extends InputStream

A DataInputStream allows to read java basic data types from an InputStream. Additionally, the endianess of the contained data can be specified.

A DataInputStream can not be instantiated directly, instead an instance must be created through the static method createDataInputStream( InputStream in, int endianess).


Field Summary
static int BIG_ENDIAN
          Big endian mode.
static int LITTLE_ENDIAN
          Little endian mode.
 
Constructor Summary
DataInputStream()
           
 
Method Summary
static DataInputStream createDataInputStream(InputStream in)
          Creates a new DataInputStream with big endian data format.
static DataInputStream createDataInputStream(InputStream in, int endianess)
          Creates a new DataInputStream.
abstract  boolean readBoolean()
          Reads a boolean value, represented by a byte value of 0 (false) of 1 (true), from the stream.
abstract  char readChar()
          Reads a char value from the stream.
abstract  double readDouble()
          Reads a double value from the stream.
abstract  float readFloat()
          Reads a float value from the stream.
abstract  int readInt()
          Reads an int value from the stream.
abstract  long readLong()
          Reads a long value from the stream.
abstract  short readShort()
          Reads a short value from the stream.
 
Methods inherited from class jcontrol.io.InputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Field Detail

BIG_ENDIAN

public static final int BIG_ENDIAN
Big endian mode.

See Also:
Constant Field Values

LITTLE_ENDIAN

public static final int LITTLE_ENDIAN
Little endian mode.

See Also:
Constant Field Values
Constructor Detail

DataInputStream

public DataInputStream()
Method Detail

createDataInputStream

public static DataInputStream createDataInputStream(InputStream in,
                                                    int endianess)
Creates a new DataInputStream.
Note: No assumptions on the type of the returned DataInputStream is allowed, because it may vary over different platforms.

Parameters:
in - InputStream to use
endianess - BIG_ENDIAN or LITTLE_ENDIAN
Returns:
DataInputStream

createDataInputStream

public static DataInputStream createDataInputStream(InputStream in)
Creates a new DataInputStream with big endian data format.
Note: No assumptions on the type of the returned DataInputStream is allowed, because it may vary over different platforms.

Parameters:
in - InputStream to use
Returns:
DataInputStream

readBoolean

public abstract boolean readBoolean()
                             throws IOException
Reads a boolean value, represented by a byte value of 0 (false) of 1 (true), from the stream.

Returns:
boolean value
Throws:
IOException - occurs on I/O error or when the stream is closed

readChar

public abstract char readChar()
                       throws IOException
Reads a char value from the stream.

Returns:
char value
Throws:
IOException - occurs on I/O error or when the stream is closed

readShort

public abstract short readShort()
                         throws IOException
Reads a short value from the stream.

Returns:
short value
Throws:
IOException - occurs on I/O error or when the stream is closed

readInt

public abstract int readInt()
                     throws IOException
Reads an int value from the stream.

Returns:
int value
Throws:
IOException - occurs on I/O error or when the stream is closed

readLong

public abstract long readLong()
                       throws IOException
Reads a long value from the stream.

Returns:
long value
Throws:
IOException - occurs on I/O error or when the stream is closed

readFloat

public abstract float readFloat()
                         throws IOException
Reads a float value from the stream.

Returns:
float value
Throws:
IOException - occurs on I/O error or when the stream is closed

readDouble

public abstract double readDouble()
                           throws IOException
Reads a double value from the stream.

Returns:
double value
Throws:
IOException - occurs on I/O error or when the stream is closed