org.freehep.util.io
Class ByteOrderInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.freehep.util.io.DecompressableInputStream
-
- org.freehep.util.io.BitInputStream
-
- org.freehep.util.io.ByteOrderInputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.io.DataInput, java.lang.AutoCloseable
- Direct Known Subclasses:
- ByteCountInputStream
public class ByteOrderInputStream extends BitInputStream implements java.io.DataInput
Class to read bytes and pairs of bytes in both little and big endian order.
-
-
Constructor Summary
Constructors Constructor and Description ByteOrderInputStream(java.io.InputStream in)Create a byte order (big-endian) input stream from given stream.ByteOrderInputStream(java.io.InputStream in, boolean littleEndian)Create a byte order input stream from given stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description java.lang.StringreadAsciiZString()Read an ascii-z (0 terminated c-string).booleanreadBoolean()bytereadByte()Read a signed byte.byte[]readByte(int n)Read n bytes and return in byte array.charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()Read a signed integer.int[]readInt(int n)Read n ints and return in int array.java.lang.StringreadLine()Deprecated.longreadLong()shortreadShort()Read a signed short.short[]readShort(int n)Read n shorts and return in short arrayjava.lang.StringreadString()Read a string (UTF).intreadUnsignedByte()Read an unsigned byte.int[]readUnsignedByte(int n)Read n unsigned bytes and return in int array.longreadUnsignedInt()Read an unsigned integer.long[]readUnsignedInt(int n)Read n unsigned ints and return in long array.intreadUnsignedShort()Read an unsigned short.int[]readUnsignedShort(int n)Read n unsigned shorts and return in int arrayjava.lang.StringreadUTF()intskipBytes(int n)-
Methods inherited from class org.freehep.util.io.BitInputStream
byteAlign, readBitFlag, readFBits, readSBits, readUBits
-
Methods inherited from class org.freehep.util.io.DecompressableInputStream
read, skip, startDecompressing
-
-
-
-
Constructor Detail
-
ByteOrderInputStream
public ByteOrderInputStream(java.io.InputStream in)
Create a byte order (big-endian) input stream from given stream.- Parameters:
in- stream to read from
-
ByteOrderInputStream
public ByteOrderInputStream(java.io.InputStream in, boolean littleEndian)Create a byte order input stream from given stream.- Parameters:
in- stream to read fromlittleEndian- true if stream should be little endian.
-
-
Method Detail
-
readFully
public void readFully(byte[] b) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
skipBytes
public int skipBytes(int n) throws java.io.IOException- Specified by:
skipBytesin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOException- Specified by:
readBooleanin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException- Specified by:
readCharin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOExceptionRead a signed byte.- Specified by:
readBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readByte
public byte[] readByte(int n) throws java.io.IOExceptionRead n bytes and return in byte array.- Parameters:
n- number of bytes to read- Returns:
- byte array
- Throws:
java.io.IOException- if read fails
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOExceptionRead an unsigned byte.- Specified by:
readUnsignedBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedByte
public int[] readUnsignedByte(int n) throws java.io.IOExceptionRead n unsigned bytes and return in int array.- Parameters:
n- number of bytes to read- Returns:
- int array
- Throws:
java.io.IOException- if read fails
-
readShort
public short readShort() throws java.io.IOExceptionRead a signed short.- Specified by:
readShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readShort
public short[] readShort(int n) throws java.io.IOExceptionRead n shorts and return in short array- Parameters:
n- number of shorts to read- Returns:
- short array
- Throws:
java.io.IOException- if read fails
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOExceptionRead an unsigned short.- Specified by:
readUnsignedShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedShort
public int[] readUnsignedShort(int n) throws java.io.IOExceptionRead n unsigned shorts and return in int array- Parameters:
n- number of shorts to read- Returns:
- int array
- Throws:
java.io.IOException- if read fails
-
readInt
public int readInt() throws java.io.IOExceptionRead a signed integer.- Specified by:
readIntin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readInt
public int[] readInt(int n) throws java.io.IOExceptionRead n ints and return in int array.- Parameters:
n- number of ints to read- Returns:
- int array
- Throws:
java.io.IOException- if read fails
-
readUnsignedInt
public long readUnsignedInt() throws java.io.IOExceptionRead an unsigned integer.- Returns:
- long
- Throws:
java.io.IOException- if read fails
-
readUnsignedInt
public long[] readUnsignedInt(int n) throws java.io.IOExceptionRead n unsigned ints and return in long array.- Parameters:
n- number of ints to read- Returns:
- long array
- Throws:
java.io.IOException- if read fails
-
readLong
public long readLong() throws java.io.IOException- Specified by:
readLongin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOExceptionDeprecated.- Specified by:
readLinein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readString
public java.lang.String readString() throws java.io.IOExceptionRead a string (UTF).- Returns:
- string
- Throws:
java.io.IOException- if read fails
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readAsciiZString
public java.lang.String readAsciiZString() throws java.io.IOExceptionRead an ascii-z (0 terminated c-string).- Returns:
- string
- Throws:
java.io.IOException- if read fails
-
-
DMelt 3.0 © DataMelt by jWork.ORG