com.tagtraum.perf.io
Class XtendedDataInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--java.io.DataInputStream
                    |
                    +--com.tagtraum.perf.io.XtendedDataInputStream
All Implemented Interfaces:
java.io.DataInput

public class XtendedDataInputStream
extends java.io.DataInputStream

Stream that can read bits und halfbytes.

Version:
$Id: $
Author:
Hendrik Schreiber
See Also:
XtendedDataOutputStream

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
XtendedDataInputStream(java.io.InputStream in)
           
 
Method Summary
 void discard()
          If less than a full byte was read, calling this method discards the remaining bits of the current byte.
 boolean readBit()
          Reads a bit from the underlying stream.
 int readHalfByte()
          Reads half a byte from the underlying stream.
 
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XtendedDataInputStream

public XtendedDataInputStream(java.io.InputStream in)
Method Detail

readBit

public boolean readBit()
                throws java.io.IOException
Reads a bit from the underlying stream. Note: If you are trying to read more bits than were originally written, you will always get values for a multiple of 8 bits. I.e. if you have written 4 bits, you will nevertheless be able to read 8 bits. The bits not explicitly written will default to false when read.

Returns:
true for 1 and false for 0
Throws:
java.io.EOFException - when the end of this stream has been reached.
java.io.IOException

readHalfByte

public int readHalfByte()
                 throws java.io.IOException
Reads half a byte from the underlying stream. Note: If you are trying to read more half bytes than were originally written, you will always get values for a multiple of bytes (not half bytes). I.e. if you have written half a byte, you will nevertheless be able to read a full byte. The bits not explicitly written will default to false when read.

Returns:
half a byte
Throws:
java.io.EOFException - when the end of this stream has been reached.
java.io.IOException

discard

public void discard()
             throws java.io.IOException
If less than a full byte was read, calling this method discards the remaining bits of the current byte.

java.io.IOException


Copyright © 2002 Hendrik Schreiber
http://www.tagtraum.com/performance/
This software can be distributed under LGPL