Package com.ibm.fhir.persistence.util
Class InputOutputByteStream
- java.lang.Object
-
- com.ibm.fhir.persistence.util.InputOutputByteStream
-
@NotThreadSafe public class InputOutputByteStream extends Object
A byte buffer which supports both InputStream and OutputStream interfaces without needless copying of (potentially large) byte arrays. Not intended for multi-threaded access (no synchronization).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InputOutputByteStream.ReshapeStrategy
Strategy for how we resize the buffer.
-
Constructor Summary
Constructors Constructor Description InputOutputByteStream(byte[] adoptBuffer, int offset)
InputOutputByteStream(int initialCapacity)
Create a buffer with the given capacity and defaultInputOutputByteStream.ReshapeStrategy
InputOutputByteStream(int initialCapacity, InputOutputByteStream.ReshapeStrategy strat)
Create a buffer with a given capacity and override theInputOutputByteStream.ReshapeStrategy
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
inputStream()
Provide a new InputStream with its own dedicated position starting at 0 offsetOutputStream
outputStream()
Return a new output stream backed by the byte buffer managed by this.void
reset()
Reset the offset to make the buffer appear empty.int
size()
How many bytes have been written to the byte buffer
-
-
-
Constructor Detail
-
InputOutputByteStream
public InputOutputByteStream(int initialCapacity)
Create a buffer with the given capacity and defaultInputOutputByteStream.ReshapeStrategy
-
InputOutputByteStream
public InputOutputByteStream(byte[] adoptBuffer, int offset)
-
InputOutputByteStream
public InputOutputByteStream(int initialCapacity, InputOutputByteStream.ReshapeStrategy strat)
Create a buffer with a given capacity and override theInputOutputByteStream.ReshapeStrategy
- Parameters:
initialCapacity
-strat
-
-
-
Method Detail
-
size
public int size()
How many bytes have been written to the byte buffer- Returns:
-
outputStream
public OutputStream outputStream()
Return a new output stream backed by the byte buffer managed by this.- Returns:
- Throws:
IllegalStateException
- if called after the mode has been flipped to read.
-
inputStream
public InputStream inputStream()
Provide a new InputStream with its own dedicated position starting at 0 offset- Returns:
-
reset
public void reset()
Reset the offset to make the buffer appear empty. Does not change the current length (capacity). Note that any streams currently being used to read the data will end.
-
-