DataSink

General purpose writable byte data sink.

API

DataSink.java
interface DataSink {
  void writeAll(ThrowingConsumer<OutputStream> outputStreamConsumer)     (1)
  DataSink none()     (2)
  DataSink ofOutputStreamSupplier(ThrowingSupplier<OutputStream> outputStreamSupplier)
  DataSink ofByteArrayConsumer(ThrowingConsumer<byte[]> byteArrayConsumer, int initalBufferSize)
  DataSink ofByteArrayConsumer(ThrowingConsumer<byte[]> byteArrayConsumer)
  DataSink ofFile(File file)
  DataSink ofStringConsumer(Consumer<String> stringConsumer, Charset charset)
  DataSink ofStringUtf8Consumer(Consumer<String> stringUtf8Consumer)
  DataSink ofStringConsumer(StringBuilder stringConsumer, Charset charset)
  DataSink ofStringUtf8Consumer(StringBuilder stringUtf8Consumer)     (3)
}
1 writeAll(ThrowingConsumer)

Offers this DataSink 's OutputStream to the caller, so it can write data to it.

2 none()

Acts as a no-op.

3 ofStringUtf8Consumer(StringBuilder)

Example:

Members

writeAll(ThrowingConsumer)

Offers this DataSink 's OutputStream to the caller, so it can write data to it.

none()

Acts as a no-op.

ofStringUtf8Consumer(StringBuilder)

Example:

var sb = new StringBuffer();
var dataSink = DataSink.ofStringUtf8Consumer(sb);
//... write to dataSink
String result = sb.toString(); // read the buffer