Package i2p.susi.util

Class MemoryBuffer

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

public class MemoryBuffer extends Object implements Buffer
Buffer backed by a byte array. Use for small amounts of data only.
Since:
0.9.34
  • Constructor Details

    • MemoryBuffer

      public MemoryBuffer()
    • MemoryBuffer

      public MemoryBuffer(int size)
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface Buffer
      Returns:
      new ByteArrayInputStream
      Throws:
      IOException
    • getOutputStream

      public OutputStream getOutputStream()
      Specified by:
      getOutputStream in interface Buffer
      Returns:
      new or existing ByteArrayOutputStream
    • readComplete

      public void readComplete(boolean success)
      Description copied from interface: Buffer
      Top-level reader MUST call this to close the input stream.
      Specified by:
      readComplete in interface Buffer
    • writeComplete

      public void writeComplete(boolean success)
      Deletes the data if success is false
      Specified by:
      writeComplete in interface Buffer
      Parameters:
      success - if false, deletes any resources
    • getLength

      public int getLength()
      Current size.
      Specified by:
      getLength in interface Buffer
    • getOffset

      public int getOffset()
      Specified by:
      getOffset in interface Buffer
      Returns:
      0 always
    • getContent

      public byte[] getContent()
      Returns:
      content if writeComplete(true) was called, otherwise null
    • toString

      public String toString()
      Overrides:
      toString in class Object