edu.emory.mathcs.util.io
Class BufferedDataInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byedu.emory.mathcs.util.io.BufferedDataInputStream
All Implemented Interfaces:
java.io.DataInput

public class BufferedDataInputStream
extends java.io.InputStream
implements java.io.DataInput

Buffered data input that additionally supports deserialization of arrays of primitive types.

Version:
1.0
Author:
Tomasz Wrzosek

Field Summary
protected  byte[] arr
          Deprecated.  
 
Constructor Summary
BufferedDataInputStream(java.io.InputStream in)
          Deprecated. Constructs buffered data input stream.
BufferedDataInputStream(java.io.InputStream in, int buffer_size)
          Deprecated. Constructs buffered data input stream.
 
Method Summary
 int available()
          Deprecated. Returns the number of available bytes in the stream.
 void close()
          Deprecated. Closes input stream
 boolean markSupported()
          Deprecated. Returns whether mark operation is supported.
 int read()
          Deprecated. Reads one byte of range 0 to 255, inclusive.
 int read(byte[] array)
          Deprecated. Reads at most array.length bytes into the array array.
 int read(byte[] array, int off, int lng)
          Deprecated. Reads lng bytes into the array array begining at offset off.
 boolean readBoolean()
          Deprecated. Reads a boolean from the stream.
 boolean[] readBooleans(boolean[] array, int off, int lng)
          Deprecated. Reads exactly lng of booleans from the stream and stores them in the array starting from off.
 byte readByte()
          Deprecated. Reads a byte from the stream.
 byte[] readBytes(byte[] array, int off, int lng)
          Deprecated. Reads exactly lng of bytes from the stream and stores them in the array starting from off.
 char readChar()
          Deprecated. Reads a char from the stream.
 char[] readChars(char[] array, int off, int lng)
          Deprecated. Reads exactly lng of chars (2*lng bytes) from the stream and stores them in the array starting from off.
 double readDouble()
          Deprecated. Reads a double from the stream.
 double[] readDoubles(double[] array, int off, int lng)
          Deprecated. Reads exactly lng of doubles (8*lng bytes) from the stream and stores them in the array starting from off.
 float readFloat()
          Deprecated. Reads a float from the stream.
 float[] readFloats(float[] array, int off, int lng)
          Deprecated. Reads exactly lng of floats (4*lng bytes) from the stream and stores them in the array starting from off.
 void readFully(byte[] bytes)
          Deprecated. Reads an array of bytes from the stream into the array.
 void readFully(byte[] bytes, int off, int lng)
          Deprecated. Reads an array of bytes from the stream into the array.
 int readInt()
          Deprecated. Reads an integer from the stream.
 int[] readInts(int[] array, int off, int lng)
          Deprecated. Reads exactly lng of integers (4*lng bytes) from the stream and stores them in the array starting from off.
 java.lang.String readLine()
          Deprecated. Does not convert chars properly.
 long readLong()
          Deprecated. Reads a long from the stream.
 long[] readLongs(long[] array, int off, int lng)
          Deprecated. Reads exactly lng of longs (8*lng bytes) from the stream and stores them in the array starting from off.
 short readShort()
          Deprecated. Reads a short from the stream.
 short[] readShorts(short[] array, int off, int lng)
          Deprecated. Reads exactly lng of shorts (2*lng bytes) from the stream and stores them in the array starting from off.
protected  java.lang.String readStringUTFBytes(int lng)
          Deprecated.  
 int readUnsignedByte()
          Deprecated. Reads an unsigned byte from the stream.
 int readUnsignedShort()
          Deprecated. Reads an unsigned short from the stream.
 java.lang.String readUTF()
          Deprecated. Reads a string in the UTF format from the stream.
 long skip(long skip)
          Deprecated. Skips at most skip bytes.
 int skipBytes(int skip)
          Deprecated. Skips at most skip bytes.
 
Methods inherited from class java.io.InputStream
mark, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arr

protected final byte[] arr
Deprecated. 
Constructor Detail

BufferedDataInputStream

public BufferedDataInputStream(java.io.InputStream in)
                        throws java.io.IOException
Deprecated. 
Constructs buffered data input stream.

Parameters:
in - the underlying input stream.

BufferedDataInputStream

public BufferedDataInputStream(java.io.InputStream in,
                               int buffer_size)
                        throws java.io.IOException
Deprecated. 
Constructs buffered data input stream.

Parameters:
in - the underlying input stream.
buffer_size - the size of the data buffer
Method Detail

read

public int read(byte[] array)
         throws java.io.IOException
Deprecated. 
Reads at most array.length bytes into the array array.

Returns:
number of actually read bytes
Throws:
java.io.IOException

read

public int read(byte[] array,
                int off,
                int lng)
         throws java.io.IOException
Deprecated. 
Reads lng bytes into the array array begining at offset off.

Returns:
number of actually read bytes
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Deprecated. 
Reads one byte of range 0 to 255, inclusive.

Throws:
java.io.IOException

markSupported

public boolean markSupported()
Deprecated. 
Returns whether mark operation is supported. Current implementation dos not support mark/reset.

Returns:
false

available

public int available()
              throws java.io.IOException
Deprecated. 
Returns the number of available bytes in the stream.

Throws:
java.io.IOException

skip

public long skip(long skip)
          throws java.io.IOException
Deprecated. 
Skips at most skip bytes.

Returns:
the number of bytes actually skipped.
Throws:
java.io.IOException

skipBytes

public int skipBytes(int skip)
              throws java.io.IOException
Deprecated. 
Skips at most skip bytes.

Specified by:
skipBytes in interface java.io.DataInput
Returns:
the number of bytes actually skipped.
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Deprecated. 
Closes input stream

Throws:
java.io.IOException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Deprecated. 
Reads a boolean from the stream.

Specified by:
readBoolean in interface java.io.DataInput
Throws:
java.io.IOException

readByte

public byte readByte()
              throws java.io.IOException
Deprecated. 
Reads a byte from the stream.

Specified by:
readByte in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedByte

public int readUnsignedByte()
                     throws java.io.IOException
Deprecated. 
Reads an unsigned byte from the stream.

Specified by:
readUnsignedByte in interface java.io.DataInput
Throws:
java.io.IOException

readChar

public char readChar()
              throws java.io.IOException
Deprecated. 
Reads a char from the stream.

Specified by:
readChar in interface java.io.DataInput
Throws:
java.io.IOException

readShort

public short readShort()
                throws java.io.IOException
Deprecated. 
Reads a short from the stream.

Specified by:
readShort in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException
Deprecated. 
Reads an unsigned short from the stream.

Specified by:
readUnsignedShort in interface java.io.DataInput
Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
Deprecated. 
Reads an integer from the stream.

Specified by:
readInt in interface java.io.DataInput
Throws:
java.io.IOException

readLong

public long readLong()
              throws java.io.IOException
Deprecated. 
Reads a long from the stream.

Specified by:
readLong in interface java.io.DataInput
Throws:
java.io.IOException

readFloat

public float readFloat()
                throws java.io.IOException
Deprecated. 
Reads a float from the stream.

Specified by:
readFloat in interface java.io.DataInput
Throws:
java.io.IOException

readDouble

public double readDouble()
                  throws java.io.IOException
Deprecated. 
Reads a double from the stream.

Specified by:
readDouble in interface java.io.DataInput
Throws:
java.io.IOException

readBytes

public byte[] readBytes(byte[] array,
                        int off,
                        int lng)
                 throws java.io.IOException
Deprecated. 
Reads exactly lng of bytes from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no bytes are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readBooleans

public boolean[] readBooleans(boolean[] array,
                              int off,
                              int lng)
                       throws java.io.IOException
Deprecated. 
Reads exactly lng of booleans from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no booleans are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readChars

public char[] readChars(char[] array,
                        int off,
                        int lng)
                 throws java.io.IOException
Deprecated. 
Reads exactly lng of chars (2*lng bytes) from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no chars are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readShorts

public short[] readShorts(short[] array,
                          int off,
                          int lng)
                   throws java.io.IOException
Deprecated. 
Reads exactly lng of shorts (2*lng bytes) from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no shorts are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readInts

public int[] readInts(int[] array,
                      int off,
                      int lng)
               throws java.io.IOException
Deprecated. 
Reads exactly lng of integers (4*lng bytes) from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no ints are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readFloats

public float[] readFloats(float[] array,
                          int off,
                          int lng)
                   throws java.io.IOException
Deprecated. 
Reads exactly lng of floats (4*lng bytes) from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no floats are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readLongs

public long[] readLongs(long[] array,
                        int off,
                        int lng)
                 throws java.io.IOException
Deprecated. 
Reads exactly lng of longs (8*lng bytes) from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no longs are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readDoubles

public double[] readDoubles(double[] array,
                            int off,
                            int lng)
                     throws java.io.IOException
Deprecated. 
Reads exactly lng of doubles (8*lng bytes) from the stream and stores them in the array starting from off.

If array is null NullPointerException is thrown.

If off is negative, or lng is negative, or off+lng is grater than array length then IndexOutOfBoundsException is thrown.

If lng is 0 or array length is 0 then no doubles are read.

If EOF is reached before the lng of bytes is read then EOFException is thrown.

Returns:
an array of read bytes
Throws:
java.io.IOException - when I/O error occurs, or EOFException when EOF is reached during the reading.

readUTF

public java.lang.String readUTF()
                         throws java.io.IOException
Deprecated. 
Reads a string in the UTF format from the stream.

Specified by:
readUTF in interface java.io.DataInput
Throws:
java.io.IOException

readStringUTFBytes

protected java.lang.String readStringUTFBytes(int lng)
                                       throws java.io.IOException
Deprecated. 
Throws:
java.io.IOException

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Deprecated. Does not convert chars properly.

Reads a string from the stream.

Specified by:
readLine in interface java.io.DataInput
Throws:
java.io.IOException

readFully

public void readFully(byte[] bytes)
               throws java.io.IOException
Deprecated. 
Reads an array of bytes from the stream into the array. This method blocks until bytes length of bytes is available. It calls readBytes(bytes, 0, bytes.length).

Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException
See Also:
readBytes(byte[],int,int)

readFully

public void readFully(byte[] bytes,
                      int off,
                      int lng)
               throws java.io.IOException
Deprecated. 
Reads an array of bytes from the stream into the array. This method blocks until bytes lng of bytes is available. It calls readBytes(bytes, off, lng).

Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException
See Also:
readBytes(byte[],int,int)