java.lang.Object
i2p.susi.util.OutputStreamBuffer
All Implemented Interfaces:
Buffer

public class OutputStreamBufferextends Object implements Buffer
Write-only Buffer implementation.
  • Field Details

    • _out

      private final OutputStream _out
      Where the buffered bytes are written.
  • Constructor Details

    • OutputStreamBuffer

      public OutputStreamBuffer(OutputStream out)
      Create an OutputStreamBuffer wrapping the given output stream.
      Parameters:
      out - the output stream to write to
  • Method Details

    • getInputStream

      public InputStream getInputStream()
      This class only forwards writes to the wrapped stream, so it exposes no readable data of its own.
      Specified by:
      getInputStream in interface Buffer
      Returns:
      InputStream for reading
      Throws:
      UnsupportedOperationException - always, since there is nothing to read
    • getOutputStream

      public OutputStream getOutputStream()
      Stream that collects writes into the buffer.
      Specified by:
      getOutputStream in interface Buffer
      Returns:
      the same OutputStream that was passed to the constructor
    • readComplete

      public void readComplete(boolean success)
      Does nothing.
      Specified by:
      readComplete in interface Buffer
      Parameters:
      success - if false, the read is considered failed
    • writeComplete

      public void writeComplete(boolean success)
      Close the output stream.
      Specified by:
      writeComplete in interface Buffer
      Parameters:
      success - ignored; the stream is closed unconditionally
    • getLength

      public int getLength()
      Bytes written so far.
      Specified by:
      getLength in interface Buffer
      Returns:
      0 always
    • getOffset

      public int getOffset()
      Current write position in the array.
      Specified by:
      getOffset in interface Buffer
      Returns:
      0 always
    • toString

      public String toString()
      Overrides:
      toString in class Object