Interface Output

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable
    All Known Implementing Classes:
    ChannelOutput, StreamOutput

    public interface Output
    extends java.io.Closeable
    The Output interface abstract the output target of CryptoOutputStream so that different implementation of output can be used. The implementation Output interface will usually wraps an output mechanism such as OutputStream or WritableByteChannel.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Closes this output and releases any system resources associated with the under layer output.
      void flush()
      Flushes this output and forces any buffered output bytes to be written out if the under layer output method support.
      int write​(java.nio.ByteBuffer src)
      Writes a sequence of bytes to this output from the given buffer.
    • Method Detail

      • close

        void close()
            throws java.io.IOException
        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
        Throws:
        java.io.IOException - if an I/O error occurs.
      • flush

        void flush()
            throws java.io.IOException
        Flushes this output and forces any buffered output bytes to be written out if the under layer output method support. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        int write​(java.nio.ByteBuffer src)
           throws java.io.IOException
        Writes a sequence of bytes to this output from the given buffer.

        An attempt is made to write up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is, src.remaining(), at the moment this method is invoked.

        Suppose that a byte sequence of length n is written, where 0 <= n <=  r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment this method is invoked; the index of the last byte written will be p + n -  1. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

        Parameters:
        src - The buffer from which bytes are to be retrieved.
        Returns:
        The number of bytes written, possibly zero.
        Throws:
        java.io.IOException - If some other I/O error occurs.