TextReader (object)

バージョン 1.12.0 で追加.

The TextReader is used to read ascii data from files.

参考

TextWriter

TextReader TextReader TextReader FileReader FileReader TextReader->FileReader

/*
** Example: TextReader
*/

require FileIO;
  
operator entry() {

  FilePath path = FilePath('${TEMP}/textWriter.txt').expandEnvVars();
  {
    TextWriter writer = TextWriter(path.string());
    writer.writeLine("Fabric");
    writer.writeLine("Engine");
    writer.writeLine("FileIO");
    writer.writeLine("Extension");
    report('Ascii file written.');
  }
  
  if(path.exists())
  {
    TextReader reader = TextReader(path.string());
    report(reader.readLine());
    report(reader.readLine());
    report(reader.readLine());
    report(reader.readLine());
    report('Ascii file read.');
  }
  
}

/*
** Output:

Ascii file written.
Fabric
Engine
FileIO
Extension
Ascii file read.

*/

Methods

  TextReader ( in String filePath )
  TextReader ( in TextReader other )
  TextReader ()
TextReader clone ? ()
Boolean close ! ()
Boolean eof ? ()
Boolean isOpen ? ()
Boolean open ! ( in String filePath )
UInt64 pos ? ()
String readAll ! ()
String readLine ! ()
  seek ! ( in UInt64 pos )
UInt64 size ? ()
  ~TextReader ()

Methods in detail

TextReader ( in String filePath )

constructs a new reader object with a given filePath


TextReader ( in TextReader other )

copy constructor


TextReader ()

standard constructor


TextReader TextReader.clone? ()

clone method


Boolean TextReader.close! ()

closes a currently opened file, returns true if successful


Boolean TextReader.eof? ()

returns true if the file has reached its end


Boolean TextReader.isOpen? ()

returns true if the file is currently open


Boolean TextReader.open! ( in String filePath )

opens a new readable file, returns true if successful


UInt64 TextReader.pos? ()

tells the position of the stream


String TextReader.readAll! ()

reads the whole content out of the currently opened file


String TextReader.readLine! ()

reads a line out of the currently opened file


TextReader.seek! ( in UInt64 pos )

sets the position of the stream


UInt64 TextReader.size? ()

returns the size of the opened file


~ TextReader ()

standard destructor