public class BinaryInputStream
extends java.io.FilterInputStream
Modifier and Type | Field and Description |
---|---|
static int |
BIG_ENDIAN |
static int |
BYTE_CHAR |
static int |
LITTLE_ENDIAN |
Constructor and Description |
---|
BinaryInputStream(java.io.InputStream in)
Creates a new BinaryInputStream from an input stream.
|
BinaryInputStream(java.io.InputStream in,
int flags)
Creates a new BinaryInputStream from an input stream and prescribed set
of flag values.
|
Modifier and Type | Method and Description |
---|---|
int |
getByteCount()
Returns the total number of bytes that have been read by this stream.
|
int |
getFlags()
Gets the flags for this stream.
|
boolean |
isLittleEndian()
Returns
true if this stream converts its input from
little-endian where appropriate. |
void |
mark(int readlimit) |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
boolean |
readBoolean()
Reads a boolean value from this stream.
|
byte |
readByte()
Reads a byte value from this stream.
|
char |
readChar()
Reads a character value from this stream.
|
double |
readDouble()
Reads a double value from this stream.
|
float |
readFloat()
Reads a float value from this stream.
|
void |
readFully(byte[] b)
Reads an array of bytes from this stream.
|
void |
readFully(byte[] b,
int off,
int len)
Reads
len bytes from an input stream and stores them in
buf starting at off . |
int |
readInt()
Reads an integer value from this stream.
|
long |
readLong()
Reads a long value from this stream.
|
double |
readLongDouble()
Reads a long-double (quad-precision) value from this stream
(128-bit double), converting to a regular double.
|
long[] |
readLongLong()
Reads a long-long value from this stream (128-bit long).
|
short |
readShort()
Reads a short value from this stream.
|
int |
readUnsignedByte()
Reads an unsigned byte value from this stream.
|
int |
readUnsignedShort()
Reads an unsigned short value from this stream.
|
java.lang.String |
readUTF()
Reads a UTF-8 string from this stream.
|
void |
reset() |
void |
setByteChar(boolean bytechar)
Sets whether or not this stream uses byte-length characters as opposed to
2-byte word characters.
|
void |
setFlags(int flags)
Sets the flags for this stream.
|
void |
setLittleEndian(boolean little)
Sets whether or not this stream converts its input from little-endian.
|
long |
skip(long n) |
int |
skipBytes(int n)
Skips over
n bytes from this stream. |
boolean |
usesByteChar()
Returns
true if this stream uses byte-length characters as
opposed to 2-byte word characters. |
public static final int BIG_ENDIAN
public static final int LITTLE_ENDIAN
public static final int BYTE_CHAR
public BinaryInputStream(java.io.InputStream in)
in
- underlying input streampublic BinaryInputStream(java.io.InputStream in, int flags)
in
- underlying input streamflags
- flag valuespublic void setFlags(int flags)
flags
- new flag valuespublic int getFlags()
public boolean isLittleEndian()
true
if this stream converts its input from
little-endian where appropriate.true
if this stream converts from little-endianpublic void setLittleEndian(boolean little)
little
- if true
, enables little-endian conversion.public boolean usesByteChar()
true
if this stream uses byte-length characters as
opposed to 2-byte word characters.true
if this stream uses byte-length characterspublic void setByteChar(boolean bytechar)
bytechar
- if true
, enables byte-length characters.public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterInputStream
java.io.IOException
public final void readFully(byte[] b) throws java.io.IOException
b
- array in which to store the bytesjava.io.IOException
public final void readFully(byte[] b, int off, int len) throws java.io.IOException
len
bytes from an input stream and stores them in
buf
starting at off
.b
- array in which to store the bytesoff
- starting offset for storing byteslen
- number of bytes to readjava.io.IOException
public final int skipBytes(int n) throws java.io.IOException
n
bytes from this stream.n
- number of bytes to skipjava.io.IOException
public void mark(int readlimit)
mark
in class java.io.FilterInputStream
public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
public final boolean readBoolean() throws java.io.IOException
java.io.IOException
public final byte readByte() throws java.io.IOException
java.io.IOException
public final int readUnsignedByte() throws java.io.IOException
java.io.IOException
public final short readShort() throws java.io.IOException
isLittleEndian()
returns
true
, then the byte order is switched from
little-endian to big-endian.java.io.IOException
public final int readUnsignedShort() throws java.io.IOException
isLittleEndian()
returns true
, then the byte order is switched from
little-endian to big-endian.java.io.IOException
public final char readChar() throws java.io.IOException
usesByteChar()
returns
true
or false
. In the latter case, if isLittleEndian()
returns true
, then the byte order is
switched from little-endian to big-endian.java.io.IOException
public final int readInt() throws java.io.IOException
isLittleEndian()
returns true
, then the byte order is switched from
little-endian to big-endian.java.io.IOException
public final long readLong() throws java.io.IOException
isLittleEndian()
returns true
, then the byte order is switched from
little-endian to big-endian.java.io.IOException
public final long[] readLongLong() throws java.io.IOException
isLittleEndian()
returns true
, then
the byte order is switched from little-endian to big-endian.
The returned pair of longs reads hi-half, low-half.java.io.IOException
public double readLongDouble() throws java.io.IOException
isLittleEndian()
returns true
, then
the byte order is switched from little-endian to big-endian.java.io.IOException
- if an I/O or syntax error occurredpublic final float readFloat() throws java.io.IOException
isLittleEndian()
returns true
, then the byte order is switched from
little-endian to big-endian.java.io.IOException
public final double readDouble() throws java.io.IOException
isLittleEndian()
returns true
, then the byte order is switched from
little-endian to big-endian.java.io.IOException
public final java.lang.String readUTF() throws java.io.IOException
java.io.IOException
public int getByteCount()