OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // Utility script to echo stdin to stdout or stderr or both. | 5 // Utility script to echo stdin to stdout or stderr or both. |
6 | 6 |
| 7 import "dart:convert"; |
7 import "dart:io"; | 8 import "dart:io"; |
8 | 9 |
9 main() { | 10 main() { |
10 var subscription; | 11 var subscription; |
11 subscription = stdin | 12 subscription = stdin |
12 .transform(new StringDecoder()) | 13 .transform(new StringDecoder()) |
13 .transform(new LineTransformer()) | 14 .transform(new LineSplitter()) |
14 .listen((String line) { | 15 .listen((String line) { |
15 // Unsubscribe after the first line. | 16 // Unsubscribe after the first line. |
16 subscription.cancel(); | 17 subscription.cancel(); |
17 }); | 18 }); |
18 } | 19 } |
OLD | NEW |