Read Complete File to Array of Lines

Jesse Phillips Jessekphillips+D at gmail.com
Fri May 11 11:02:52 PDT 2012


On Friday, 11 May 2012 at 15:00:18 UTC, 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

Something like:

import std.file;
import std.string;

void main() {
      foreach(line; readText("file.in").splitLines()) ...
}


More information about the Digitalmars-d-learn mailing list