org.monte.media.io
Class AppendableByteArrayInputStream
java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.monte.media.io.AppendableByteArrayInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class AppendableByteArrayInputStream
- extends java.io.ByteArrayInputStream
A ByteArrayInputStream which allows to replace the byte buffer underneath.
- Version:
- 1.0 2011-08-28 Created.
- Author:
- Werner Randelshofer
| Fields inherited from class java.io.ByteArrayInputStream |
buf, count, mark, pos |
|
Method Summary |
void |
appendBuffer(byte[] buf,
int offset,
int length,
boolean discard)
Appends new data to the buffer. |
static void |
main(java.lang.String[] args)
|
int |
read()
|
int |
read(byte[] b,
int off,
int len)
|
void |
setBuffer(byte[] buf,
int offset,
int length)
Sets the buffer and resets the stream. |
| Methods inherited from class java.io.ByteArrayInputStream |
available, close, mark, markSupported, reset, skip |
| Methods inherited from class java.io.InputStream |
read |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AppendableByteArrayInputStream
public AppendableByteArrayInputStream(byte[] buf,
int offset,
int length)
AppendableByteArrayInputStream
public AppendableByteArrayInputStream(byte[] buf)
read
public int read()
- Overrides:
read in class java.io.ByteArrayInputStream
read
public int read(byte[] b,
int off,
int len)
- Overrides:
read in class java.io.ByteArrayInputStream
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
public static void main(java.lang.String[] args)