Interface FlushSink

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FlushSink
Sink that receives buffered bytes when an OStream's buffer fills (or when OStream.flush() is called).

This is a functional interface, so a sink can be written as a lambda or a method reference — for example out::write for an OutputStream. Implementing it lets a message larger than the output buffer (or larger than RAM) be streamed out incrementally: the encoder hands the sink each full buffer and then resumes at the start of the buffer.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    flush(byte[] data, int offset, int length)
    Consume length bytes starting at offset in data.
  • Method Details

    • flush

      void flush(byte[] data, int offset, int length) throws IOException
      Consume length bytes starting at offset in data.

      The array is owned by the encoder and is reused after this call returns; a sink that needs to retain the bytes must copy them.

      Parameters:
      data - the encoder's active buffer
      offset - start of the pending bytes
      length - number of pending bytes
      Throws:
      IOException - if the underlying transport or storage fails