com.partnersoft.io.formats.binary
Class FastDataInputStream
java.lang.Object
java.io.InputStream
com.partnersoft.io.formats.binary.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:
- can be reset to point at a new InputStream w/o creating a new
FastDataInputStream object.
- combines interpretation of data with buffering (so
e.g. readInt() doesn't have to call readByte() etc.)
- is designed to create as few objects as possible - all arrays
are grown rather than instantiated, for example.
- includes methods for reading arrays of floats, ints,
etc. directly.
- Author:
- Paul Reavis
Copyright 2001 Partner Software, Inc.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FastDataInputStream
public FastDataInputStream(int bufferSize)
FastDataInputStream
public FastDataInputStream()
FastDataInputStream
public FastDataInputStream(java.io.InputStream innie)
FastDataInputStream
public FastDataInputStream(java.io.InputStream innie,
int bufferSize)
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