public class BinaryReader extends java.lang.Object implements IDisposable
Constructor and Description |
---|
BinaryReader(Stream input)
Initializes a new instance of the BinaryReader class based on the supplied stream and using UTF-8 encoding.
|
BinaryReader(Stream input,
java.lang.String encoding)
Initializes a new instance of the BinaryReader class based on the supplied stream and a specific character encoding.
|
Modifier and Type | Method and Description |
---|---|
void |
Close()
Closes the current reader and the underlying stream.
|
void |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
protected void |
Dispose(boolean disposing)
Releases the unmanaged resources used by the BinaryReader and optionally releases the managed resources.
|
protected void |
FillBuffer(int numBytes)
Fills the internal buffer with the specified number of bytes read from the stream.
|
Stream |
getBaseStream() |
int |
Read()
Reads characters from the underlying stream and advances the current position of the stream in accordance with the Encoding used and the specific character being read from the stream.
|
int |
Read(byte[] buffer,
int index,
int count)
Reads count bytes from the stream with index as the starting point in the byte array.
|
int |
Read(char[] buffer,
int index,
int count)
Reads count characters from the stream with index as the starting point in the character array.
|
protected int |
Read7BitEncodedInt() |
boolean |
ReadBoolean()
Reads a Boolean value from the current stream and advances the current position of the stream by one byte.
|
byte |
ReadByte() |
byte[] |
ReadBytes(int count)
Reads count bytes from the current stream into a byte array and advances the current position by count bytes.
|
char |
ReadChar() |
char[] |
ReadChars(int count) |
double |
ReadDouble() |
short |
ReadInt16() |
int |
ReadInt32() |
long |
ReadInt64() |
float |
ReadSingle() |
java.lang.String |
ReadString() |
public BinaryReader(Stream input)
input
- A stream.ArgumentException
- The stream does not support reading, the stream is null, or the stream is already closed.public BinaryReader(Stream input, java.lang.String encoding)
input
- The supplied stream.encoding
- The character encoding.ArgumentNullException
- input, or encoding is null.ArgumentException
- The stream does not support reading, or the stream is already closed.public Stream getBaseStream()
public void Close()
public void Dispose()
IDisposable
Dispose
in interface IDisposable
protected void Dispose(boolean disposing)
disposing
- true to release both managed and unmanaged resources; false to release only unmanaged resources.protected void FillBuffer(int numBytes)
numBytes
- The number of bytes to be read.EndOfStreamException
- The end of the stream is reached before numBytes could be read.IOException
- An I/O error occurs.ObjectDisposedException
public int Read()
ObjectDisposedException
- The stream is closed.IOException
- An I/O error occurs.public int Read(byte[] buffer, int index, int count)
buffer
- The buffer to read data into.index
- The starting point in the buffer at which to begin reading into the buffer.count
- The number of characters to read.ArgumentNullException
- buffer is null.ArgumentOutOfRangeException
- index or count is less than zero.ArgumentException
- The buffer length minus index is less than count.ObjectDisposedException
- The stream is closed.IOException
- An I/O error occurs.public int Read(char[] buffer, int index, int count)
buffer
- The buffer to read data into.index
- The starting point in the buffer at which to begin reading into the buffer.count
- The number of characters to read.ArgumentException
- The buffer length minus index is less than count.ArgumentNullException
- buffer is null.ArgumentOutOfRangeException
- index or count is negative.ObjectDisposedException
- The stream is closed.IOException
- An I/O error occurs.protected int Read7BitEncodedInt()
public boolean ReadBoolean()
ObjectDisposedException
- The stream is closed.IOException
- An I/O error occurs.EndOfStreamException
- The end of the stream is reached.public byte ReadByte()
public byte[] ReadBytes(int count)
count
- The number of bytes to read.ArgumentOutOfRangeException
- count is less than zero.ObjectDisposedException
- The stream is closed.IOException
- An I/O error occurs.public char ReadChar()
ObjectDisposedException
public char[] ReadChars(int count)
count
- ObjectDisposedException
ArgumentOutOfRangeException
- count is less than zero.public double ReadDouble()
public short ReadInt16()
public int ReadInt32()
public long ReadInt64()
public float ReadSingle()
public java.lang.String ReadString()