org.freehep.util.io
Class ByteCountInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.freehep.util.io.DecompressableInputStream
-
- org.freehep.util.io.BitInputStream
-
- org.freehep.util.io.ByteOrderInputStream
-
- org.freehep.util.io.ByteCountInputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.io.DataInput, java.lang.AutoCloseable
- Direct Known Subclasses:
- TaggedInputStream
public class ByteCountInputStream extends ByteOrderInputStream
The input buffer can be limited to less than the number of bytes of the underlying buffer. Only one real input stream exists, which is where the reads take place. A buffer is limited by some length. If more is read, -1 is returned. Multiple limits can be set by calling pushBuffer. If bytes are left in the buffer when popBuffer is called, they are returned in an array. Otherwise null is returned.
-
-
Constructor Summary
Constructors Constructor and Description ByteCountInputStream(java.io.InputStream in, boolean littleEndian, int stackDepth)Create a Byte Count input stream from given stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description longgetLength()byte[]popBuffer()Pops the buffer from the stack and returns leftover bytes in a byte arrayvoidpushBuffer(int len)Push the current buffer to the stackintread()-
Methods inherited from class org.freehep.util.io.ByteOrderInputStream
readAsciiZString, readBoolean, readByte, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readInt, readLine, readLong, readShort, readShort, readString, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedShort, readUnsignedShort, readUTF, skipBytes
-
Methods inherited from class org.freehep.util.io.BitInputStream
byteAlign, readBitFlag, readFBits, readSBits, readUBits
-
Methods inherited from class org.freehep.util.io.DecompressableInputStream
skip, startDecompressing
-
-
-
-
Constructor Detail
-
ByteCountInputStream
public ByteCountInputStream(java.io.InputStream in, boolean littleEndian, int stackDepth)Create a Byte Count input stream from given stream- Parameters:
in- stream to read fromlittleEndian- true if stream should be little endianstackDepth- maximum number of buffers used while reading
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Overrides:
readin classDecompressableInputStream- Throws:
java.io.IOException
-
pushBuffer
public void pushBuffer(int len)
Push the current buffer to the stack- Parameters:
len- number of bytes that can be read from the current buffer
-
popBuffer
public byte[] popBuffer() throws java.io.IOExceptionPops the buffer from the stack and returns leftover bytes in a byte array- Returns:
- null if buffer was completely read. Otherwise rest of buffer is read and returned.
- Throws:
java.io.IOException- if read fails
-
getLength
public long getLength()
- Returns:
- number of bytes that can be read from the current buffer
-
-
DMelt 3.0 © DataMelt by jWork.ORG