Class StreamOutput

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

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

      Fields 
      Modifier and Type Field Description
      private byte[] buf  
      private int bufferSize  
      private java.io.OutputStream out  
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamOutput​(java.io.OutputStream out, int bufferSize)
      Constructs a new instance.
    • Field Detail

      • buf

        private final byte[] buf
      • bufferSize

        private final int bufferSize
      • out

        private final java.io.OutputStream out
    • Constructor Detail

      • StreamOutput

        public StreamOutput​(java.io.OutputStream out,
                            int bufferSize)
        Constructs a new instance.
        Parameters:
        out - the OutputStream object.
        bufferSize - the buffer size.
    • 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.
      • getOut

        protected java.io.OutputStream getOut()
        Gets the output stream.
        Returns:
        the output stream.
      • 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.