Package jadex.common
Class BufferInputStream
java.lang.Object
java.io.InputStream
jadex.common.BufferInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Class for wrapping an InputStream around a ByteBuffer.
TODO: Optimize.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
read()
int
read
(byte[] b) Reads an array from the buffer.int
read
(byte[] b, int off, int len) Reads an array from the buffer.static final BufferInputStream
wrap
(ByteBuffer buffer) Wraps a byte buffer.Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
buffer
The buffer.
-
-
Constructor Details
-
BufferInputStream
Creates a new InputStream from buffer.- Parameters:
buffer
- The buffer.
-
-
Method Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
Reads an array from the buffer.- Overrides:
read
in classInputStream
- Parameters:
b
- The array.- Returns:
- Number of bytes read.
- Throws:
IOException
-
read
Reads an array from the buffer.- Overrides:
read
in classInputStream
- Parameters:
b
- The array.off
- The offset in the array.len
- Number of bytes to read.- Returns:
- Number of bytes read.
- Throws:
IOException
-
wrap
Wraps a byte buffer.- Parameters:
buffer
- The buffer.- Returns:
- InputStream based on the buffer.
-