ITextReader.ReadString

Syntax

ReadString(CharCount: Integer): String;

Parameters

CharCount. Number of characters that must be read.

Description

The ReadString method reads character string from a text file. The number of characters is passed by the CharCount parameter.

Example

Sub UserProc;
Var
    File1: IFileInfo;
    TextR: ITextReader;
    s: String;
Begin
    File1 := New FileInfo.Attach("c:\New_folder\1.txt");
    If File1.Exists Then
        TextR := File1.OpenTextReader;
        TextR.Encoding := CodePage.UTF8;
        s := TextR.ReadString(14);
    End If;
    Dispose File1;
End Sub UserProc;

After executing the example the "s" variable contains the first 14 characters read from the 1.txt file. UTF-8 encoding is used when working with file.

See also:

ITextReader