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
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
int
Current size.int
void
readComplete
(boolean success) Top-level reader MUST call this to close the input stream.toString()
void
writeComplete
(boolean success) Deletes the data if success is false
-
Constructor Details
-
MemoryBuffer
public MemoryBuffer() -
MemoryBuffer
public MemoryBuffer(int size)
-
-
Method Details
-
getInputStream
- Specified by:
getInputStream
in interfaceBuffer
- Returns:
- new ByteArrayInputStream
- Throws:
IOException
-
getOutputStream
- Specified by:
getOutputStream
in interfaceBuffer
- 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 interfaceBuffer
-
writeComplete
public void writeComplete(boolean success) Deletes the data if success is false- Specified by:
writeComplete
in 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
-