java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.monte.media.io.AppendableByteArrayInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
A
ByteArrayInputStream which allows to replace the byte buffer underneath.- Author:
- Werner Randelshofer
-
Field Summary
Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos -
Constructor Summary
ConstructorsConstructorDescriptionAppendableByteArrayInputStream(byte[] buf) AppendableByteArrayInputStream(byte[] buf, int offset, int length) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendBuffer(byte[] buf, int offset, int length, boolean discard) Appends new data to the buffer.static voidintread()intread(byte[] b, int off, int len) voidsetBuffer(byte[] buf, int offset, int length) Sets the buffer and resets the stream.Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, readAllBytes, readNBytes, reset, skip, transferToMethods inherited from class java.io.InputStream
nullInputStream, read, readNBytes, skipNBytes
-
Constructor Details
-
AppendableByteArrayInputStream
public AppendableByteArrayInputStream(byte[] buf, int offset, int length) -
AppendableByteArrayInputStream
public AppendableByteArrayInputStream(byte[] buf)
-
-
Method Details
-
read
public int read()- Overrides:
readin classByteArrayInputStream
-
read
public int read(byte[] b, int off, int len) - Overrides:
readin classByteArrayInputStream
-
appendBuffer
public void appendBuffer(byte[] buf, int offset, int length, boolean discard) Appends new data to the buffer.- Parameters:
buf- Data.offset- Offset in the data.length- Length of the data.discard- True if data which has already been read can be discarded.
-
setBuffer
public void setBuffer(byte[] buf, int offset, int length) Sets the buffer and resets the stream. This will overwrite the data array in the buffer, if it is large enough. Otherwise it will create a new data array and copy the data into it.- Parameters:
buf- Data.offset- Offset in the data.length- Length of the data.
-
main
-