I/O

article

Reading File Content

In this tutorial I'll briefly explain how one can load the content of an ASCII file into a single string.

The deferred class FILE cannot be used directly as it is deferred.

The descendant PLAIN_TEXT_FILE is what we're actually looking for.

Basic steps

The basic steps are the following:

  local
     l_file: PLAIN_TEXT_FILE
     l_content: STRING
  do
     create l_file.make_create_read_write (a_path)
     l_file.read_stream (l_file.count)
     l_content := l_file.last_string.twin
     l_file.close
  end
Syndicate content