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:
java.io.Closeable
,java.lang.AutoCloseable
class BlockedByteArrayInputStream extends java.io.InputStream
An input stream reading from a blocked byte array.
-
-
Field Summary
Fields Modifier and Type Field Description private long
pos
The current position of the stream.private BlockedByteArray
src
The underlying source.
-
Constructor Summary
Constructors Constructor Description BlockedByteArrayInputStream(BlockedByteArray src, long pos)
Creates a new input stream reading from a blocked byte array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the stream.(package private) long
getPosition()
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.
-
-
-
Field Detail
-
src
private BlockedByteArray src
The underlying source. Set tonull
when closed.
-
pos
private long pos
The current position of the stream.
-
-
Constructor Detail
-
BlockedByteArrayInputStream
public BlockedByteArrayInputStream(BlockedByteArray src, long pos)
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 Detail
-
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 classjava.io.InputStream
- Returns:
- A byte.
-
read
public int read(byte[] buf, int offset, int len)
Reads up tolen
bytes.- Overrides:
read
in classjava.io.InputStream
- 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
-
-