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