org.freehep.util.io
Class ByteOrderInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.freehep.util.io.DecompressableInputStream
          extended by org.freehep.util.io.BitInputStream
              extended by org.freehep.util.io.ByteOrderInputStream
All Implemented Interfaces:
Closeable, DataInput
Direct Known Subclasses:
ByteCountInputStream

public class ByteOrderInputStream
extends BitInputStream
implements DataInput

Class to read bytes and pairs of bytes in both little and big endian order.

Version:
$Id: ByteOrderInputStream.java 8584 2006-08-10 23:06:37Z duns $
Author:
Mark Donszelmann, Charles Loomis

Field Summary
protected  boolean little
           
 
Fields inherited from class org.freehep.util.io.BitInputStream
BIT_MASK, FIELD_MASK, MASK_SIZE, ONES, ZERO
 
Constructor Summary
ByteOrderInputStream(InputStream in)
          Create a byte order (big-endian) input stream from given stream.
ByteOrderInputStream(InputStream in, boolean littleEndian)
          Create a byte order input stream from given stream.
 
Method Summary
 String readAsciiZString()
          Read an ascii-z (0 terminated c-string).
 boolean readBoolean()
           
 byte readByte()
          Read a signed byte.
 byte[] readByte(int n)
          Read n bytes and return in byte array.
 char readChar()
           
 double readDouble()
           
 float readFloat()
           
 void readFully(byte[] b)
           
 void readFully(byte[] b, int off, int len)
           
 int readInt()
          Read a signed integer.
 int[] readInt(int n)
          Read n ints and return in int array.
 String readLine()
          Deprecated.  
 long readLong()
           
 short readShort()
          Read a signed short.
 short[] readShort(int n)
          Read n shorts and return in short array
 String readString()
          Read a string (UTF).
 int readUnsignedByte()
          Read an unsigned byte.
 int[] readUnsignedByte(int n)
          Read n unsigned bytes and return in int array.
 long readUnsignedInt()
          Read an unsigned integer.
 long[] readUnsignedInt(int n)
          Read n unsigned ints and return in long array.
 int readUnsignedShort()
          Read an unsigned short.
 int[] readUnsignedShort(int n)
          Read n unsigned shorts and return in int array
 String readUTF()
           
 int skipBytes(int n)
           
 
Methods inherited from class org.freehep.util.io.BitInputStream
byteAlign, fetchByte, readBitFlag, readFBits, readSBits, readUBits
 
Methods inherited from class org.freehep.util.io.DecompressableInputStream
read, skip, startDecompressing
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

little

protected boolean little
Constructor Detail

ByteOrderInputStream

public ByteOrderInputStream(InputStream in)
Create a byte order (big-endian) input stream from given stream.

Parameters:
in - stream to read from

ByteOrderInputStream

public ByteOrderInputStream(InputStream in,
                            boolean littleEndian)
Create a byte order input stream from given stream.

Parameters:
in - stream to read from
littleEndian - true if stream should be little endian.
Method Detail

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 n)
              throws IOException
Specified by:
skipBytes in interface DataInput
Throws:
IOException

readBoolean

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

readChar

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

readByte

public byte readByte()
              throws IOException
Read a signed byte.

Specified by:
readByte in interface DataInput
Throws:
IOException

readByte

public byte[] readByte(int n)
                throws IOException
Read n bytes and return in byte array.

Parameters:
n - number of bytes to read
Returns:
byte array
Throws:
IOException - if read fails

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Read an unsigned byte.

Specified by:
readUnsignedByte in interface DataInput
Throws:
IOException

readUnsignedByte

public int[] readUnsignedByte(int n)
                       throws IOException
Read n unsigned bytes and return in int array.

Parameters:
n - number of bytes to read
Returns:
int array
Throws:
IOException - if read fails

readShort

public short readShort()
                throws IOException
Read a signed short.

Specified by:
readShort in interface DataInput
Throws:
IOException

readShort

public short[] readShort(int n)
                  throws IOException
Read n shorts and return in short array

Parameters:
n - number of shorts to read
Returns:
short array
Throws:
IOException - if read fails

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Read an unsigned short.

Specified by:
readUnsignedShort in interface DataInput
Throws:
IOException

readUnsignedShort

public int[] readUnsignedShort(int n)
                        throws IOException
Read n unsigned shorts and return in int array

Parameters:
n - number of shorts to read
Returns:
int array
Throws:
IOException - if read fails

readInt

public int readInt()
            throws IOException
Read a signed integer.

Specified by:
readInt in interface DataInput
Throws:
IOException

readInt

public int[] readInt(int n)
              throws IOException
Read n ints and return in int array.

Parameters:
n - number of ints to read
Returns:
int array
Throws:
IOException - if read fails

readUnsignedInt

public long readUnsignedInt()
                     throws IOException
Read an unsigned integer.

Returns:
long
Throws:
IOException - if read fails

readUnsignedInt

public long[] readUnsignedInt(int n)
                       throws IOException
Read n unsigned ints and return in long array.

Parameters:
n - number of ints to read
Returns:
long array
Throws:
IOException - if read fails

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

readLine

public String readLine()
                throws IOException
Deprecated. 

Specified by:
readLine in interface DataInput
Throws:
IOException

readString

public String readString()
                  throws IOException
Read a string (UTF).

Returns:
string
Throws:
IOException - if read fails

readUTF

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

readAsciiZString

public String readAsciiZString()
                        throws IOException
Read an ascii-z (0 terminated c-string).

Returns:
string
Throws:
IOException - if read fails


Copyright © 2000-2007 FreeHEP. All Rights Reserved.