io_utils library
Miscellaneous I/O utilities. This includes reading and writing binary
data in a way that's interoperable with java.io.DataInputStream
and
java.io.DataOutputStream
.
/// Example of using [DataOutputSink] and [DataInputStream] to
/// encode values that are compatible with `java.io.DataInputStream`
/// and `java.io.DataOutputStream`
///
Future<void> data_io_stream_example() async {
final file = File.fromUri(Directory.systemTemp.uri.resolve('test.dat'));
final flushable = FlushingIOSink(file.openWrite());
final out = DataOutputSink(flushable);
out.writeUTF8('Hello, world.');
out.close();
await flushable.done;
final dis = DataInputStream(file.openRead());
print(await dis.readUTF8());
await dis.close();
await file.delete();
}
Classes
- ByteBufferDataInputStream
- A wrapper around a List
- DataInputStream
-
A coroutines-style wrapper around a
Stream<List<int>>
, like you get from a socket or a file in Dart. This lets you asynchronously read a stream using an API much likejava.io.DataInputStream
. - DataOutputSink
-
An adapter over a
Sink<List<int>>
for writing to a stream. This class presents an API based on Java'sjava.io.DataOutputStream
. - EOFException