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:convert"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 main() { | 10 main() { |
11 var subscription; | 11 var subscription; |
12 subscription = stdin | 12 subscription = stdin |
13 .transform(new StringDecoder()) | 13 .transform(UTF8.decoder) |
14 .transform(new LineSplitter()) | 14 .transform(new LineSplitter()) |
15 .listen((String line) { | 15 .listen((String line) { |
16 // Unsubscribe after the first line. | 16 // Unsubscribe after the first line. |
17 subscription.cancel(); | 17 subscription.cancel(); |
18 }); | 18 }); |
19 } | 19 } |
OLD | NEW |