StreamReader Class

Implements a class that reads characters from a file.

Example

The following reads data from two consecutive lines of a text file (see StreamWriter for the write example):

using elsystem.io;

var: StreamReader myFile(null);

 

myFile = StreamReader.Create("c:\ExistingFolder\myTestFile.txt");

print("Line 1: ",myFile.ReadLine());

print("Line 2: ",myFile.ReadLine());

myFile.Close();

Namespace: elsystem.io

Properties
  Name Type Description
Public property EndOfStream bool Gets a value that indicates whether the current file position is at the end of the file.
Public property CurrentEncoding objects Gets the character Encoding for the current instance.
Methods
  Name Description
Public property Close() Closes the StreamReader object and the underlying file, and releases any system resources associated with the reader.
Public property Create(stream) Initializes a new instance specifying the FileStream to read.
Public property Create(stream,detectencoding) Initializes a new instance specifying the FileStream to read. Setting detectencoding to True enables byte order detection.
Public property Create(stream,enc) Initializes a new instance specifying the FileStream to read. The enc parameter specifies the character Encoding.
Public property Create(stream,enc,detectencoding) Initializes a new instance specifying the FileStream to read. The enc parameter specifies the character Encoding. Setting detectencoding to True enables byte order detection.
Public property Create(path) Initializes a new instance specifying the full path of the file to read.
Public property Create(path,detectencoding) Initializes a new instance specifying the full path of the file to read. Setting detectencoding to True enables byte order detection.
Public property Create(path,enc) Initializes a new instance specifying the full path of the file to read. The enc parameter specifies the character Encoding.
Public property Create(path,enc,detectencoding) Initializes a new instance specifying the full path of the file to read. The enc parameter specifies the character Encoding. Setting detectencoding to True enables byte order detection.
Public property Peek() Returns the next available character as an ascii value but does not consume it.
Public property PeekAsChar(string) Returns the next available character as a character value but does not consume it.
Public property Read() Reads the next character as an ascii value from the file and advances the character position by one character.
Public property Read(count, CharRead) Reads a specified maximum of characters (count) from the file into a buffer and gets the number of characters read (CharRead).
Public property ReadAsChar() Reads the next character from the file and advances the character position by one character.
Public property ReadLine() Reads a line of characters from the file and returns the data as a string.
Public property ReadToEnd() Reads the file from the current position to the end of the file.
Inheritance Hierarchy

elsystem.Object

elsystem.io.StreamReader