nom.tam.util
Class BufferedDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by nom.tam.util.BufferedDataInputStream
All Implemented Interfaces:
Closeable, DataInput

public class BufferedDataInputStream
extends BufferedInputStream
implements DataInput


Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
BufferedDataInputStream(InputStream o)
          Use the BufferedInputStream constructor
BufferedDataInputStream(InputStream o, int bufLength)
          Use the BufferedInputStream constructor
 
Method Summary
static void main(String[] args)
          This method is used to test and time the buffered data methods.
protected  int primitiveArrayRecurse(Object o)
           
protected  void primitiveEOFThrower()
           
 void printStatus()
           
 int read()
           
 int read(byte[] buf, int offset, int len)
           
 boolean readBoolean()
          Read a boolean value
protected  int readBooleanArray(boolean[] b)
           
 byte readByte()
           
 char readChar()
           
protected  int readCharArray(char[] c)
           
 double readDouble()
           
protected  int readDoubleArray(double[] d)
           
 float readFloat()
           
protected  int readFloatArray(float[] f)
           
 void readFully(byte[] b)
           
 void readFully(byte[] b, int off, int len)
           
 int readInt()
           
protected  int readIntArray(int[] i)
           
 String readLine()
          Deprecated.  
 long readLong()
           
protected  int readLongArray(long[] l)
           
 int readPrimitiveArray(Object o)
          This routine provides efficient reading of arrays of any primitive type.
 short readShort()
           
protected  int readShortArray(short[] s)
           
 int readUnsignedByte()
           
 int readUnsignedShort()
           
 String readUTF()
           
 long skip(long offset)
           
 int skipBytes(int toSkip)
           
 String toString()
           
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferedDataInputStream

public BufferedDataInputStream(InputStream o)
Use the BufferedInputStream constructor


BufferedDataInputStream

public BufferedDataInputStream(InputStream o,
                               int bufLength)
Use the BufferedInputStream constructor

Method Detail

read

public int read(byte[] buf,
                int offset,
                int len)
         throws IOException
Overrides:
read in class BufferedInputStream
Throws:
IOException

read

public int read()
         throws IOException
Overrides:
read in class BufferedInputStream
Throws:
IOException

skip

public long skip(long offset)
          throws IOException
Overrides:
skip in class BufferedInputStream
Throws:
IOException

readBoolean

public boolean readBoolean()
                    throws IOException
Read a boolean value

Specified by:
readBoolean in interface DataInput
Parameters:
b - The value to be written. Externally true is represented as a byte of 1 and false as a byte value of 0.
Throws:
IOException

readByte

public byte readByte()
              throws IOException
Specified by:
readByte in interface DataInput
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Specified by:
readUnsignedByte in interface DataInput
Throws:
IOException

readInt

public int readInt()
            throws IOException
Specified by:
readInt in interface DataInput
Throws:
IOException

readShort

public short readShort()
                throws IOException
Specified by:
readShort in interface DataInput
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Specified by:
readUnsignedShort in interface DataInput
Throws:
IOException

readChar

public char readChar()
              throws IOException
Specified by:
readChar in interface DataInput
Throws:
IOException

readLong

public long readLong()
              throws IOException
Specified by:
readLong in interface DataInput
Throws:
IOException

readFloat

public float readFloat()
                throws IOException
Specified by:
readFloat in interface DataInput
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException
Specified by:
readDouble in interface DataInput
Throws:
IOException

readFully

public void readFully(byte[] b)
               throws IOException
Specified by:
readFully in interface DataInput
Throws:
IOException

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws IOException
Specified by:
readFully in interface DataInput
Throws:
IOException

skipBytes

public int skipBytes(int toSkip)
              throws IOException
Specified by:
skipBytes in interface DataInput
Throws:
IOException

readUTF

public String readUTF()
               throws IOException
Specified by:
readUTF in interface DataInput
Throws:
IOException

readLine

public String readLine()
                throws IOException
Deprecated. 

This routine uses the deprecated DataInputStream.readLine() method. However, we really want to simulate the behavior of that method so that's what we used.

Specified by:
readLine in interface DataInput
Throws:
IOException

readPrimitiveArray

public int readPrimitiveArray(Object o)
                       throws IOException
This routine provides efficient reading of arrays of any primitive type. It is an error to invoke this method with an object that is not an array of some primitive type. Note that there is no corresponding capability to writePrimitiveArray in BufferedDataOutputStream to read in an array of Strings.

Parameters:
o - The object to be read. It must be an array of a primitive type, or an array of Object's.
Throws:
IOException

primitiveArrayRecurse

protected int primitiveArrayRecurse(Object o)
                             throws IOException
Throws:
IOException

readBooleanArray

protected int readBooleanArray(boolean[] b)
                        throws IOException
Throws:
IOException

readShortArray

protected int readShortArray(short[] s)
                      throws IOException
Throws:
IOException

readCharArray

protected int readCharArray(char[] c)
                     throws IOException
Throws:
IOException

readIntArray

protected int readIntArray(int[] i)
                    throws IOException
Throws:
IOException

readLongArray

protected int readLongArray(long[] l)
                     throws IOException
Throws:
IOException

readFloatArray

protected int readFloatArray(float[] f)
                      throws IOException
Throws:
IOException

readDoubleArray

protected int readDoubleArray(double[] d)
                       throws IOException
Throws:
IOException

primitiveEOFThrower

protected void primitiveEOFThrower()
                            throws EOFException
Throws:
EOFException

printStatus

public void printStatus()

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)
                 throws Exception
This method is used to test and time the buffered data methods. Note that the BufferedDataOutputStream.main simply calls this method which is used to test both classes in conjunction.

Throws:
Exception