java.io.Closeable
, java.lang.AutoCloseable
public class ByteArrayCombinerStream
extends java.io.InputStream
Modifier and Type | Field | Description |
---|---|---|
private int |
arrayIndex |
Index of the array we are currently reading from.
|
private java.util.ArrayList<byte[]> |
arrays |
A list of the arrays to combine.
|
private byte[] |
curArray |
The array we are currently reading from.
|
private long |
gOffset |
Global offset into the whole stream.
|
private int |
off |
The local offset into the current array.
|
private long |
specifiedLength |
Length of the stream.
|
Constructor | Description |
---|---|
ByteArrayCombinerStream(java.util.ArrayList<byte[]> arraysIn,
long length) |
Create a stream whose source is a list of byte arrays.
|
Modifier and Type | Method | Description |
---|---|---|
int |
available() |
Return the number of available bytes.
|
private byte[] |
nextArray() |
Fetch the next array to read data from.
|
int |
read() |
Read a single byte.
|
int |
read(byte[] buf,
int offset,
int length) |
Reads up to len bytes of data from the input stream into an array of
bytes.
|
private final java.util.ArrayList<byte[]> arrays
private final long specifiedLength
private long gOffset
private int arrayIndex
private byte[] curArray
private int off
public ByteArrayCombinerStream(java.util.ArrayList<byte[]> arraysIn, long length)
arraysIn
- an ArrayList
with references to the source
byte arrays. The references are copied to a new
ArrayList
instance.length
- the length of the stream. Never published outside
this object. Note that the length specified can be shorter
than the actual number of bytes in the byte arrays.java.lang.IllegalArgumentException
- if there is less data available than
specified by length
, or length
is
negative.public int read() throws java.io.IOException
read
in class java.io.InputStream
-1
if the end-of-stream is reachedjava.io.IOException
public int read(byte[] buf, int offset, int length) throws java.io.IOException
len
bytes, but
a smaller number may be read. The number of bytes actually read
is returned as an integer.read
in class java.io.InputStream
buf
- the array to copy bytes intooffset
- offset into the arraylength
- the maximum number of bytes to read-1
if end-of-stream
is reachedjava.io.IOException
public int available()
available
in class java.io.InputStream
private byte[] nextArray()
ArrayList
is cleared when the array
is "taken out".byte[]
-object, or null
if there are
no more arraysApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.