Class ChannelOutput

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Output

    public class ChannelOutput
    extends java.lang.Object
    implements Output
    The ChannelOutput class takes a WritableByteChannel object and wraps it as Output object acceptable by CryptoOutputStream as the output target.
    • Field Detail

      • channel

        private final java.nio.channels.WritableByteChannel channel
    • Constructor Detail

      • ChannelOutput

        public ChannelOutput​(java.nio.channels.WritableByteChannel channel)
        Constructs a ChannelOutput.
        Parameters:
        channel - the WritableByteChannel object.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Overrides the Output.close(). Closes this output and releases any system resources associated with the under layer output.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface Output
        Throws:
        java.io.IOException - if an I/O error occurs.
      • flush

        public void flush()
                   throws java.io.IOException
        Overrides the Output.flush(). Flushes this output and forces any buffered output bytes to be written out if the under layer output method support.
        Specified by:
        flush in interface Output
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        public int write​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Overrides the Output.write(ByteBuffer). Writes a sequence of bytes to this output from the given buffer.
        Specified by:
        write in interface Output
        Parameters:
        src - The buffer from which bytes are to be retrieved.
        Returns:
        The number of bytes written, possibly zero.
        Throws:
        java.io.IOException - if an I/O error occurs.