Description |
The next Byte is read from the current stream, and returned as an Integer. If the stream was already exhasuted, then -1 is returned instead.
The stream position is updated accordingly.
|
|
Microsoft MSDN Links |
System.IO
System.IO.FileStream
|
|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
Stream : System.IO.FileStream;
ByteAsInteger : Integer;
begin
// Open the file for writing
Stream := System.IO.FileStream.Create('C:\DelphiBasics.txt',
FileMode.Create);
// Write to the file
Stream.WriteByte(65); // Chr(65) = 'A'
Stream.WriteByte(66); // Chr(66) = 'B'
Stream.WriteByte(67); // Chr(67) = 'C'
// Move to the start of the file
Stream.Seek(0, SeekOrigin.Begin);
// Display the contents
ByteAsInteger := Stream.ReadByte;
while ByteAsInteger >= 0 do
begin
Console.Write(Char(ByteAsInteger));
ByteAsInteger := Stream.ReadByte;
end;
// Close the stream
Stream.Close;
Console.Readline;
end.
| Show full unit code | ABC
|
|
|
|