Home  |  Delphi .net Home  |  System.IO.StringReader  |  ReadToEnd Method
  
ReadToEnd  
Method  
Reads to the end of the current string
StringReader Class
System.IO NameSpace
CF1.  Function ReadToEnd : String;
CF : Methods with this mark are Compact Framework Compatible
Description
If the current string has not been exhausted, the remaining characters are returned in a string.
 
Carriage return and Line-feed characters are not returned by this method.
Notes
You must set the length of the target Character array, and it must have sufficient capacity to hold the returned characters.
Microsoft MSDN Links
System.IO
System.IO.StringReader
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
Reading to the end of the string
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Reader           : System.IO.StringReader;
  MultiLineString  : String;
  CharAsInteger    : Integer;

begin
  // Define our multi line string
  MultiLineString := 'Hello' + Chr(13) + Chr(10) +
                     'cruel' + Chr(13) + Chr(10) +
                     'World';

  // Create our String Reader
  Reader := System.IO.StringReader.Create(MultiLineString);

  // Keep reading but stop before the first 'r'
  while Reader.Peek <> Ord('r') do
  begin
    CharAsInteger := Reader.Read;

    if CharAsInteger = 13  // Carriage Return
    then Console.Write('[CR]')
    else if CharAsInteger = 10  // Line-feed
    then Console.Write('[LF]')
    else Console.Write(Char(CharAsInteger));
  end;

  Console.WriteLine;
  Console.WriteLine;
  Console.WriteLine('Now reading to the end of the string :');
  Console.WriteLine;
  Console.WriteLine(Reader.ReadToEnd);

  Console.Readline;
end.
   Hello[CR][LF]c
  
   Now reading to the end of the string :
  
   ruel
   World
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author