D Documentation  
read
void[] read(char[] name)

This function reads a file name and returns an array of bytes.
It can throw a FileException, if the file does not exist (anymore) or can not be read.

Example:
// Import standard-in-out
import std.stdio;
import std.file;

// Main function
int main(char[][] args)
{
  char[] content;
  // This program reads a file and prints it to the screen
  try
  {
    content = cast(char[])read(args[1]);
    writefln(content);
  }
  catch (FileException xy)
  {
    writefln();
    writefln("A file exception occured: " ~ xy.toString());
  }
  catch (Exception xx)
  {
    writefln();
    writefln("An exception occured: " ~ xx.toString());
  }
  return 0;
}

See also:
FileException, exists, isfile, write, append, remove, rename
Created using PHP docwiki written by Markus Dangl. Best viewed with Mozilla Firefox.