Package org.jboss.marshalling
Class ByteBufferInput
java.lang.Object
java.io.InputStream
org.jboss.marshalling.ByteBufferInput
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteInput
An
InputStream
which implements ByteInput
and reads bytes from a ByteBuffer
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.void
close()
int
read()
Reads the next byte of data from the input stream.int
read
(byte[] b) Read some bytes from the input stream into the given array.int
read
(byte[] b, int off, int len) Read some bytes from the input stream into the given array.long
skip
(long n) Skips over and discards up ton
bytes of data from this input stream.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Field Details
-
buffer
-
-
Constructor Details
-
ByteBufferInput
Construct a new instance.- Parameters:
buffer
- the buffer to read from
-
-
Method Details
-
read
Reads the next byte of data from the input stream. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
read
in interfaceByteInput
- Specified by:
read
in classInputStream
- Returns:
- the next byte, or -1 if the end of stream has been reached
- Throws:
IOException
- if an error occurs
-
read
Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.- Specified by:
read
in interfaceByteInput
- Overrides:
read
in classInputStream
- Parameters:
b
- the destination array- Returns:
- the number of bytes read (possibly zero), or -1 if the end of stream has been reached
- Throws:
IOException
- if an error occurs
-
read
Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.- Specified by:
read
in interfaceByteInput
- Overrides:
read
in classInputStream
- Parameters:
b
- the destination arrayoff
- the offset into the array into which data should be readlen
- the number of bytes to attempt to fill in the destination array- Returns:
- the number of bytes read (possibly zero), or -1 if the end of stream has been reached
- Throws:
IOException
- if an error occurs
-
available
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.- Specified by:
available
in interfaceByteInput
- Overrides:
available
in classInputStream
- Returns:
- the number of bytes
- Throws:
IOException
- if an error occurs
-
skip
Skips over and discards up ton
bytes of data from this input stream. If the end of stream is reached, this method returns0
in order to be consistent withInputStream.skip(long)
.- Specified by:
skip
in interfaceByteInput
- Overrides:
skip
in classInputStream
- Parameters:
n
- the number of bytes to attempt to skip- Returns:
- the number of bytes skipped
- Throws:
IOException
- if an error occurs
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-