Mercurial > projects > ldc
comparison tango/example/conduits/lineio.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
1 | |
2 private import tango.io.Console, | |
3 tango.io.FileConduit; | |
4 | |
5 private import tango.text.stream.LineIterator; | |
6 | |
7 /******************************************************************************* | |
8 | |
9 Read a file line-by-line, sending each one to the console. This | |
10 illustrates how to bind a conduit to a stream iterator (iterators | |
11 also support the binding of a buffer). Note that stream iterators | |
12 are templated for char, wchar and dchar types. | |
13 | |
14 *******************************************************************************/ | |
15 | |
16 void main (char[][] args) | |
17 { | |
18 if (args.length is 2) | |
19 { | |
20 // open a file for reading | |
21 scope file = new FileConduit (args[1]); | |
22 | |
23 // process file one line at a time | |
24 foreach (line; new LineIterator!(char)(file)) | |
25 Cout (line).newline; | |
26 } | |
27 else | |
28 Cout ("usage: lineio filename").newline; | |
29 } |