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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide | 8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide |
9 * utility functions for writing to the StreamConsumer directly. The | 9 * utility functions for writing to the StreamConsumer directly. The |
10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], | 10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 } | 92 } |
93 if (string.isEmpty) return; | 93 if (string.isEmpty) return; |
94 writeBytes(_encodeString(string, _encoding)); | 94 writeBytes(_encodeString(string, _encoding)); |
95 } | 95 } |
96 | 96 |
97 void writeAll(Iterable objects) { | 97 void writeAll(Iterable objects) { |
98 for (Object obj in objects) write(obj); | 98 for (Object obj in objects) write(obj); |
99 } | 99 } |
100 | 100 |
101 void writeln(Object obj) { | 101 void writeln([Object obj = ""]) { |
102 write(obj); | 102 write(obj); |
103 write("\n"); | 103 write("\n"); |
104 } | 104 } |
105 | 105 |
106 void writeCharCode(int charCode) { | 106 void writeCharCode(int charCode) { |
107 write(new String.fromCharCode(charCode)); | 107 write(new String.fromCharCode(charCode)); |
108 } | 108 } |
109 | 109 |
110 void writeBytes(List<int> data) { | 110 void writeBytes(List<int> data) { |
111 if (_isBound) { | 111 if (_isBound) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 }, | 225 }, |
226 onError: _controller.addError); | 226 onError: _controller.addError); |
227 if (_paused) _pause(); | 227 if (_paused) _pause(); |
228 if (unbind) { | 228 if (unbind) { |
229 return _writeStreamCompleter.future; | 229 return _writeStreamCompleter.future; |
230 } else { | 230 } else { |
231 return _pipeFuture; | 231 return _pipeFuture; |
232 } | 232 } |
233 } | 233 } |
234 } | 234 } |
OLD | NEW |