Interface MessageSink.Provider

Enclosing interface:
MessageSink

public static interface MessageSink.Provider
Adapts a MessageSink to an I/O abstraction such as WritableByteChannel or OutputStream.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the underlying I/O abstraction.
    void
    Flushes the underlying I/O abstraction.
    default long
    transferFrom(ReadableByteChannel channel, long length, ByteBuffer buffer)
    Transfers up to length bytes from the given channel to the underlying I/O abstraction.
    void
    write(ByteBuffer buffer)
    Writes the remaining bytes of the given byte buffer to the underlying I/O abstraction.
    void
    write(ByteBuffer... buffers)
    Writes the remaining bytes of the given byte buffers to the underlying I/O abstraction.
  • Method Details

    • write

      void write(ByteBuffer buffer) throws IOException
      Writes the remaining bytes of the given byte buffer to the underlying I/O abstraction.
      Parameters:
      buffer - the byte buffer to read from
      Throws:
      IOException - if an I/O error occurs
    • write

      void write(ByteBuffer... buffers) throws IOException
      Writes the remaining bytes of the given byte buffers to the underlying I/O abstraction.
      Parameters:
      buffers - the byte buffers to read from
      Throws:
      IOException - if an I/O error occurs
    • flush

      void flush() throws IOException
      Flushes the underlying I/O abstraction.
      Throws:
      IOException - if an I/O error occurs
    • close

      void close() throws IOException

      Closes the underlying I/O abstraction.

      This method is called at most once. No other method is called after this method.

      Throws:
      IOException - if an I/O error occurs
    • transferFrom

      default long transferFrom(ReadableByteChannel channel, long length, ByteBuffer buffer) throws IOException

      Transfers up to length bytes from the given channel to the underlying I/O abstraction.

      Fewer than length bytes may be transferred if the channel's end of input is reached.

      Parameters:
      channel - the channel to transfer bytes from
      length - the number of bytes to transfer
      buffer - A buffer whose remaining bytes must be transferred before transferring length bytes from the given channel. The buffer can also be used for transferring bytes from the channel.
      Returns:
      the actual number of bytes transferred (between 0 and length)
      Throws:
      IOException - if an I/O error occurs