Package i2p.susi.util
Class MemoryBuffer
java.lang.Object
i2p.susi.util.MemoryBuffer
- All Implemented Interfaces:
Buffer
Buffer backed by a byte array.
Use for small amounts of data only.
- Since:
- 0.9.34
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]intCurrent size.intvoidreadComplete(boolean success) Top-level reader MUST call this to close the input stream.toString()voidwriteComplete(boolean success) Deletes the data if success is false
-
Constructor Details
-
MemoryBuffer
public MemoryBuffer() -
MemoryBuffer
public MemoryBuffer(int size)
-
-
Method Details
-
getInputStream
- Specified by:
getInputStreamin interfaceBuffer- Returns:
- new ByteArrayInputStream
- Throws:
IOException
-
getOutputStream
- Specified by:
getOutputStreamin interfaceBuffer- Returns:
- new or existing ByteArrayOutputStream
-
readComplete
public void readComplete(boolean success) Description copied from interface:BufferTop-level reader MUST call this to close the input stream.- Specified by:
readCompletein interfaceBuffer
-
writeComplete
public void writeComplete(boolean success) Deletes the data if success is false- Specified by:
writeCompletein interfaceBuffer- Parameters:
success- if false, deletes any resources
-
getLength
public int getLength()Current size. -
getOffset
public int getOffset() -
getContent
public byte[] getContent()- Returns:
- content if writeComplete(true) was called, otherwise null
-
toString
-