Package org.apache.derby.impl.io.vfmem
Class BlockedByteArrayInputStream
java.lang.Object
java.io.InputStream
org.apache.derby.impl.io.vfmem.BlockedByteArrayInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An input stream reading from a blocked byte array.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
The current position of the stream.private BlockedByteArray
The underlying source. -
Constructor Summary
ConstructorsConstructorDescriptionBlockedByteArrayInputStream
(BlockedByteArray src, long pos) Creates a new input stream reading from a blocked byte array. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the stream.(package private) long
Returns the current position.int
read()
Reads a single byte.int
read
(byte[] buf, int offset, int len) Reads up tolen
bytes.(package private) void
setPosition
(long newPos) Sets the position.Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
src
The underlying source. Set tonull
when closed. -
pos
private long posThe current position of the stream.
-
-
Constructor Details
-
BlockedByteArrayInputStream
Creates a new input stream reading from a blocked byte array.- Parameters:
src
- the source blocked byte arraypos
- the initial position to start reading from
-
-
Method Details
-
setPosition
void setPosition(long newPos) Sets the position.- Parameters:
newPos
- the new byte position
-
getPosition
long getPosition()Returns the current position.- Returns:
- The current byte position.
-
read
public int read()Reads a single byte.- Specified by:
read
in classInputStream
- Returns:
- A byte.
-
read
public int read(byte[] buf, int offset, int len) Reads up tolen
bytes.- Overrides:
read
in classInputStream
- Parameters:
buf
- destination bufferoffset
- offset into the destination bufferlen
- number of bytes to read- Returns:
- The number of bytes read.
-
close
public void close()Closes the stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
-