public class BinaryReader extends InputStream
BinaryInputStream is
also extended to provide support for reading from other
"chunked" byte sources.BinaryBuilder| Modifier and Type | Field and Description |
|---|---|
protected long |
absolutePosition
The total number of bytes read
|
protected byte[] |
buffer
The current token value
|
protected int |
position
The offset of the next byte to read in the token
|
protected int |
size
The size of the current token
|
protected InputStream |
source
The underlying byte stream
|
| Constructor and Description |
|---|
BinaryReader(byte[] bytes)
Wraps a byte array with a byte-oriented reader.
|
BinaryReader(InputStream source,
int bufferSize)
Wraps an
InputStream with a byte-oriented reader having
extended function. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close()
Closes the wrapped port and releases any allocated resources.
|
long |
getAbsolutePosition()
Gets the current position in the
underlying data.
|
boolean |
isEmpty()
Indicates whether the byte stream for reading has been exhausted.
|
void |
mark(int readlimit)
Marking the stream is not a supported operation.
|
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
int |
readBase128Int()
Reads a base-128 encoded int value from the stream.
|
long |
readBase128Long()
Reads a base-128 encoded long value from the stream.
|
byte |
readByte()
Reads a single byte from the stream.
|
byte[] |
readBytes(int len)
Reads a specified number of bytes from the stream.
|
char |
readChar()
Reads a character value from the stream.
|
char[] |
readChars(int count)
Reads a specified number of character values from the
stream.
|
double |
readDouble()
Reads a double value from the stream.
|
float |
readFloat()
Reads a float value from the stream.
|
int |
readInt()
Reads an int value from the stream.
|
long |
readLong()
Reads a long value from the stream.
|
char[] |
readSingleByteChars(int count)
Reads a specified number of character values from the
stream, assuming the bytes are the least-significant
bytes of the values.
|
int |
readUnsignedBase128Int()
Reads a base-128 encoded int value from the stream,
assuming an unsigned encoding.
|
long |
readUnsignedBase128Long()
Reads a base-128 encoded long value from the stream,
assuming an unsigned encoding.
|
void |
reset()
Resetting the stream is not a supported operation.
|
long |
skip(long n) |
void |
skipBytes(long count)
Advances the read position in the stream the
specified number of bytes.
|
String |
toString() |
protected InputStream source
protected byte[] buffer
protected int position
protected int size
protected long absolutePosition
public BinaryReader(InputStream source, int bufferSize)
InputStream with a byte-oriented reader having
extended function. If an IOException is thrown by the
wrapped source, the provided stream will be closed.
The wrapped stream should not be accessed directly after creating the stream. Doing so may result in unexpected or otherwise unpredictable behavior in both the stream and the wrapper.
source - the stream to wrapbufferSize - the size of the read buffer to use,
in bytes. Data will be read in chunks of this size from the
wrapped stream.public BinaryReader(byte[] bytes)
bytes - the byte array to wrap.public int read()
throws IOException
read in class InputStreamIOExceptionpublic final int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic final int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic int available()
available in class InputStreampublic final long getAbsolutePosition()
public final boolean markSupported()
markSupported in class InputStreampublic final void mark(int readlimit)
mark in class InputStreamUnsupportedOperationException - alwayspublic final void reset()
reset in class InputStreamUnsupportedOperationException - alwayspublic final void close()
close in interface Closeableclose in interface AutoCloseableclose in class InputStreampublic boolean isEmpty()
true if no more bytes are
available to be read, false otherwise.public void skipBytes(long count)
count - the number of bytes to skippublic byte readByte()
public byte[] readBytes(int len)
len - the number of bytes to readlen bytes starting at
the current positionpublic char readChar()
public char[] readChars(int count)
count - the number of characters to readcount characters starting at
the current positionpublic char[] readSingleByteChars(int count)
count - the number of characters to readcount characters starting at
the current positionpublic int readInt()
public int readUnsignedBase128Int()
BinaryBuilder.appendUnsignedBase128(int)public int readBase128Int()
BinaryBuilder.appendBase128(int)public long readLong()
public long readUnsignedBase128Long()
BinaryBuilder.appendUnsignedBase128(long)public long readBase128Long()
BinaryBuilder.appendBase128(int)public float readFloat()
Float.intBitsToFloat(int).public double readDouble()
Double.longBitsToDouble(long).Copyright © 2016 Actian Corporation. All rights reserved.