Interface Output

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ChannelOutput, StreamOutput

public interface Output extends 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

    Modifier and Type
    Method
    Description
    void
    Closes this output and releases any system resources associated with the under layer output.
    void
    Flushes this output and forces any buffered output bytes to be written out if the under layer output method support.
    int
    Writes a sequence of bytes to this output from the given buffer.
  • Method Details

    • close

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

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

      int write(ByteBuffer src) throws 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:
      IOException - If some other I/O error occurs.