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, and support for using Pointycastle to encrypt or decrypt a stream of data, somewhat like javax.crytpo.CipherInputStream and javax.crypto.CypherOutputStream.

/// 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 like java.io.DataInputStream.
DataOutputSink
An adapter over a Sink<List<int>> for writing to a stream. This class presents an API based on Java's java.io.DataOutputStream.
DecryptingStream
A wrapper around a DataInputStream that decrypts using a Pointycastle BlockCipher, resulting in a Stream<List<int>>. This is functionally similar to javax.crypto.CipherInputStream.
EncryptingSink
A wrapper around a Sink<List<int>> that encrypts data using a Pointycastle BlockCipher. This sink needs to buffer to build up blocks that can be encrypted, so it's essential that close() be called. This is functionally similar to javax.crypto.CipherOutputStream
EOFException