com.partnersoft.io.formats
Class FastDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.partnersoft.io.formats.FastDataInputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

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

A self-buffering data input stream. Has the following advantages over the usual DataInputStream->BufferedInputStream setup:

Author:
Paul Reavis Copyright 2001 Partner Software, Inc.

Constructor Summary
FastDataInputStream()
           
FastDataInputStream(java.io.InputStream innie)
           
FastDataInputStream(java.io.InputStream innie, int bufferSize)
           
FastDataInputStream(int bufferSize)
           
 
Method Summary
 int available()
           
 void close()
           
 long getPosition()
           
 void mark(int readLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void read(ByteBuffer buffer, int numBytes)
           
 java.lang.String readASCII(int bytecount)
           
 boolean readBoolean()
           
 byte readByte()
           
 char readChar()
           
 double readDouble()
           
 float readFloat()
           
 FloatBuffer readFloats(int numFloats)
          Reads an entire array of floats in at once and returns them as a FloatBuffer - which you should treat as read only, here me?
 void readFully(byte[] b)
           
 void readFully(byte[] b, int off, int len)
           
 int readInt()
           
 short readInt16()
           
 int readInt32()
           
 int readInt8()
           
 java.lang.String readLine()
           
 int readLine(byte[] b)
          Reads until it hits some end of line (\r, \n) character or until buffer is full.
 long readLong()
           
 short readShort()
           
 int readUInt16()
           
 long readUInt32()
           
 int readUInt8()
           
 int readUnsignedByte()
           
 long readUnsignedInt()
           
 int readUnsignedShort()
           
 java.lang.String readUTF()
           
 CharBuffer readUTFAsBuffer()
           
 void reset()
           
 void setInput(java.io.InputStream innie)
           
 long skip(long n)
           
 int skipBytes(int n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastDataInputStream

public FastDataInputStream(int bufferSize)

FastDataInputStream

public FastDataInputStream()

FastDataInputStream

public FastDataInputStream(java.io.InputStream innie)

FastDataInputStream

public FastDataInputStream(java.io.InputStream innie,
                           int bufferSize)
Method Detail

read

public void read(ByteBuffer buffer,
                 int numBytes)
          throws java.io.IOException
Throws:
java.io.IOException

getPosition

public long getPosition()

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int readLimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

readFully

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

readLine

public int readLine(byte[] b)
             throws java.io.IOException
Reads until it hits some end of line (\r, \n) character or until buffer is full. Fills with nulls, returns actual length. This method should probably not be mixed with others, due to possible weirdnesses in overlap, since it is of indeterminate actual bytelength.

Throws:
java.io.IOException

readFully

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

skipBytes

public int skipBytes(int n)
              throws java.io.IOException
Specified by:
skipBytes in interface java.io.DataInput
Throws:
java.io.IOException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Specified by:
readBoolean in interface java.io.DataInput
Throws:
java.io.IOException

readByte

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

readUnsignedByte

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

readShort

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

readUnsignedShort

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

readChar

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

readUnsignedInt

public long readUnsignedInt()
                     throws java.io.IOException
Throws:
java.io.IOException

readInt

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

readLong

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

readFloat

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

readDouble

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

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Specified by:
readLine in interface java.io.DataInput
Throws:
java.io.IOException

readUTF

public java.lang.String readUTF()
                         throws java.io.IOException
Specified by:
readUTF in interface java.io.DataInput
Throws:
java.io.IOException

readASCII

public java.lang.String readASCII(int bytecount)
                           throws java.io.IOException
Throws:
java.io.IOException

readUInt8

public int readUInt8()
              throws java.io.IOException
Throws:
java.io.IOException

readInt8

public int readInt8()
             throws java.io.IOException
Throws:
java.io.IOException

readInt32

public int readInt32()
              throws java.io.IOException
Throws:
java.io.IOException

readUInt32

public long readUInt32()
                throws java.io.IOException
Throws:
java.io.IOException

readInt16

public short readInt16()
                throws java.io.IOException
Throws:
java.io.IOException

readUInt16

public int readUInt16()
               throws java.io.IOException
Throws:
java.io.IOException

setInput

public void setInput(java.io.InputStream innie)

readFloats

public FloatBuffer readFloats(int numFloats)
                       throws java.io.IOException
Reads an entire array of floats in at once and returns them as a FloatBuffer - which you should treat as read only, here me?

Throws:
java.io.IOException

readUTFAsBuffer

public CharBuffer readUTFAsBuffer()
                           throws java.io.IOException
Throws:
java.io.IOException