Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

This document has been placed into the public domain by Kris


        Read a file line-by-line, sending each one to the console. This
        illustrates how to bind a conduit to a text iterator. Iterators
        also support the binding of buffer and string instances.

        Note that iterators are templated for char, wchar and dchar ~ 
        this example uses char

private import,

private import;

void main (char[][] args)

          if (args.length is 2)
           // open a file for reading
           auto file = new File (args[1]);

           // create a line oriented iterator, and use it to sweep the file
           foreach (line; new Lines!(char) (file))
                    Cout (line).newline;
           Cout ("usage: ")(args[0])(" <filename>").newline;