On 05/11/2012 05:00 PM, Paul wrote:
I would like to read a complete file in one statement and then process
it line by line.

foreach (line; MyFile)
etc.

Is it possible to read a file into and array of lines?
Thanks



---SOURCE
import std.stdio;
import std.file;

int main()
{
        writeln("start");
        foreach( line; File("src/main.d").byLine())
        {
                writeln(line);
        }
        writeln("stop");
        return 0;
}

---OUTPUT
start
import std.stdio;
import std.file;

int main()
{
        writeln("start");
        foreach( line; File("src/main.d").byLine())
        {
                writeln(line);
        }
        writeln("stop");
        return 0;
}
stop

Reply via email to