BinaryReader |
IObject |
Name | Description |
---|---|
BaseStream (get) | Returns the underlying Stream being read by the BinaryReader. |
Name | Description |
---|---|
CloseReader | Closes the reader and underlying Stream. |
Equals | Returns a boolean indicating if the value and this object instance are the same instance. |
GetHashCode | Returns a pseudo-unique number identifying this instance. |
PeekChar | Returns the next character to be decoded from the byte stream. The position in the stream is not advanced after the read. |
Read | Fills either a Byte array or Integer array with the specified number of elements. Or returns the next character to be decoded from the stream. |
ReadBoolean | Reads a Boolean value from the current stream and advances the current position of the stream by one byte. |
ReadByte | Reads the next byte in the stream, and advances the position one byte. |
ReadBytes | Reads the specified number of bytes from the stream and returns them in an array. |
ReadChar | Reads the next decode character in the stream, and advances the position the number of bytes requirece to assemble a single character. |
ReadChars |
Reads the specified number of characters from the current stream, returns the data in a character array, and advances the current position in accordance with the Encoding used and the specific character being read from the stream.
|
ReadCurrency | Reads an 8-byte Currency value from the current stream and advances the current position of the stream by eight bytes. |
ReadDate | Reads eight bytes from the stream and returns them as a Date type. |
ReadDecimal | Reads a decimal value from the current stream and advances the current position of the stream by sixteen bytes. |
ReadDouble | Reads an 8-byte floating point value from the current stream and advances the current position of the stream by eight bytes. |
ReadInt16 | Reads an 2-byte signed integer from the current stream and advances the current position of the stream by two bytes. |
ReadInt32 | Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes. |
ReadInt64 | Reads an 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes. |
ReadSingle | Reads a 4-byte floating point value from the current stream and advances the current position of the stream by four bytes. |
ReadString | Reads a string from the current stream. The string is prefixed with the length, encoded as an integer seven bits at a time. |
ToString | Returns a string representation of this object instance. |
The bytes from a stream can be read and cast to a specific data type. Each data type will determine the number of bytes to be read from the stream. Once the number of bytes have been read, they are assembled into the requested data type, advancing the position in the stream the required number of bytes.
Characters can be read from the stream using the specified Encoding. If Encoding is not specified then the BinaryReader is created using UTF8Encoding.
The following example demonstrates the two ways to create a BinaryReader object using the NewBinaryReader constructor method.
Public Sub Main() Dim Source As FileStream Dim Reader As BinaryReader Set Source = File.OpenFile("MyFile.txt", FileMode.OpenExisting) ' method one Set Reader = NewBinaryReader(Source) ' method two Set Reader = Cor.NewBinaryReader(Source) End Sub