Class StreamOutput

java.lang.Object
org.apache.commons.crypto.stream.output.StreamOutput
All Implemented Interfaces:
Closeable, AutoCloseable, Output

public class StreamOutput extends Object implements Output
The StreamOutput class takes a OutputStream object and wraps it as Output object acceptable by CryptoOutputStream as the output target.
  • Field Details

    • buf

      private final byte[] buf
    • bufferSize

      private final int bufferSize
    • out

      private final OutputStream out
  • Constructor Details

    • StreamOutput

      public StreamOutput(OutputStream out, int bufferSize)
      Constructs a new instance.
      Parameters:
      out - the OutputStream object.
      bufferSize - the buffer size.
  • Method Details

    • close

      public void close() throws IOException
      Overrides the Output.close(). 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
      Specified by:
      close in interface Output
      Throws:
      IOException - if an I/O error occurs.
    • flush

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

      protected OutputStream getOut()
      Gets the output stream.
      Returns:
      the output stream.
    • write

      public int write(ByteBuffer src) throws 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:
      IOException - if an I/O error occurs.