Home  |  Delphi .net Home  |  System.IO.StreamReader  |  ReadLine Method
ReadLine  
Method  
Reads a line of text from the current stream
StreamReader Class
System.IO NameSpace
CF1.  Function ReadLine ( ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
The next set of characters, if any, in the current stream are read into the returned string. The character read is ended by line termination (carriage return and line feed) characters, or the stream end. The line termination characters are not themselves returned.
Microsoft MSDN Links
System.IO
System.IO.StreamReader
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Reader : System.IO.StreamReader;
  Writer : System.IO.StreamWriter;

begin
  // Create our Stream Writer to write to a text file
  Writer := System.IO.StreamWriter.Create('C:\DelphiBasics.txt');

  // Write various things to our StreamWriter
  Writer.WriteLine(27);
  Writer.WriteLine(true);
  Writer.WriteLine(DateTime.Create(2004, 9, 17));

  // Close the writer
  Writer.Close;

  // Create our StreamReader
  Reader := System.IO.StreamReader.Create('C:\DelphiBasics.txt');

  // Now display the file contents
  while Reader.Peek >= 0 do
    Console.WriteLine(Reader.ReadLine);

  // Close the reader
  Reader.Close;

  Console.Readline;
end.
Show full unit code
  27
  True
  17/09/2004 00:00:00
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author