BinaryStream
Class: BinaryStream

Method PrototypeDescription
Property EOF As Boolean (read only)True of stream is at End of File, otherwise False.
Property Closed As Boolean (read only)True if stream is closed, otherwise False.
Property LastErrorCode As Integer (read only) The last error code, otherwise 0.
Property Length As UInt64 (read/write)The length of the file (in bytes). If you set the value of the stream (output stream only) to be smaller than the current value (after you wrote the file), it will truncate the file.
Property LittleEndian As Boolean (read/write)True if stream is Little Endian, otherwise False.
Property Position As UInt64 (read/write)The position of the file pointer (in bytes).
Property ReadError As Boolean (read only)-- True if an error has occurred while reading the file, otherwise False.
Property WriteError As Boolean (read only)True if an error has occurred while writing the file, otherwise False.

Sub Close()Closes the stream and releases the file handle.
Sub Constructor( mb As MemoryBlock )Creates a BinaryStream from a MemoryBlock.
Sub Constructor( s As String )Creates a BinaryStream from s. Because this makes the stream read-only, this constructor cannot be used as an output stream.
Sub Flush()Clears and saves the contents of the stream to disk.
Method Read( count As Integer ) As StringReads count bytes from the input stream and returns them as a String.
Method ReadBoolean() As BooleanReads a Boolean from the input stream and returns it as a Boolean.
Method ReadCurrency() As CurrencyReads a Currency from the input stream and returns it as a Currency.
Method ReadDouble() As DoubleReads a Double from the input stream and resturns it as a Double.
Method ReadInt16() As Int16Reads 2 bytes from the input stream and returns them as an Int16.
Method ReadInt32() As Int32Reads 4 bytes from the input stream and returns them as an Int32.
Method ReadInt64() As Int64Reads 8 bytes from the input stream and returns them as an Int64.
Method ReadInt8() As Int8Reads 1 byte from the input stream and returns it as an Int8.
Method ReadPString() As Stringreads a Pascal String from the input stream and returns it as a String.
Method ReadSingle() As DoubleReads a word from the input stream and resturns it as a Double.
Method ReadUInt16() As UInt16Reads 2 bytes from the input stream and returns them as an UInt16.
Method ReadUInt32() As UInt32Reads 4 bytes from the input stream and returns them as an UInt32.
Method ReadUInt64() As UInt64Reads 8 bytes from the input stream and returns them as an UInt64.
Method ReadUInt8() As UInt8Reads 1 byte from the input stream and returns it as an UInt8.
Sub Write( data As String )Writes data to the output stream.
Sub WriteBoolean( data As Boolean )Writes data to the output stream.
Sub WriteCurrency( data As Currency )Writes data to the output stream.
Sub WriteDouble( data As Double )Writes data to the output stream.
Sub WriteInt16( data As Int16 )Writes data to the output stream.
Sub WriteInt32( data As Int32 )Writes data to the output stream.
Sub WriteInt64( data As Int64 )Writes data to the output stream.
Sub WriteInt8( data As Int8 )Writes data to the output stream.
Sub WritePString( data As String )Writes data to the output stream.
Sub WriteSingle( data As Double )Writes data to the output stream.
Sub WriteUInt16( data As UInt16 )Writes data to the output stream.
Sub WriteUInt32( data As UInt32 )Writes data to the output stream.
Sub WriteUInt64( data As UInt64 )Writes data to the output stream.
Sub WriteUInt8( data As UInt8 )Writes data to the output stream.


The BinaryStream class is used to read and write binary files. To create a BinaryStream object, create a FolderItem object and use the openAsBinaryFile() or createBinaryFile() method. The benefit of using a BinaryStream over a TextStream is that you can read and write from any point within the file. TextOutputStream and TextInputStream only access files sequentially.

To write text files you may prefer to use the TextOutputStream class; to read text files you can use the TextInputStream class.

BinaryStream implements the Readable, Writeable, and Closeable interfaces.

The TextEncoding class is not implemented in Yuma. Thus methods or subroutines which take encodings as parameters in REALBasic drop those parameters in Yuma, and the string read is assumed to be UTF-8. Similarly the BinaryStream.Encoding property doesn't exist in Yuma.

The "Handle" features are not implemented in Yuma. Thus methods or subroutines which take handles as parameters in REALBasic drop those parameters in Yuma. Similarly the BinaryStream.Handle property doesn't exist in Yuma.