Package org.apache.commons.io.input
Class UnsynchronizedByteArrayInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.UnsynchronizedByteArrayInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
This is an alternative to
ByteArrayInputStream which removes the synchronization overhead for non-concurrent access; as such this class is
not thread-safe.
To build an instance, use UnsynchronizedByteArrayInputStream.Builder.
- Since:
- 2.7
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]The underlying data buffer.static final intThe end of stream marker.private final intEnd Of Data.private intThe current mark (if any).private intCurrent offset in the data buffer. -
Constructor Summary
ConstructorsModifierConstructorDescriptionUnsynchronizedByteArrayInputStream(byte[] data) Deprecated.UnsynchronizedByteArrayInputStream(byte[] data, int offset) Deprecated.UnsynchronizedByteArrayInputStream(byte[] data, int offset, int length) Deprecated.privateUnsynchronizedByteArrayInputStream(byte[] data, int eod, int offset, int markedOffset) -
Method Summary
Modifier and TypeMethodDescriptionintbuilder()Constructs a newUnsynchronizedByteArrayInputStream.Builder.voidmark(int readLimit) booleanprivate static intminPosLen(byte[] data, int defaultValue) intread()intread(byte[] dest) intread(byte[] dest, int off, int len) private static intrequireNonNegative(int value, String name) voidreset()longskip(long n) Methods inherited from class java.io.InputStream
close
-
Field Details
-
END_OF_STREAM
public static final int END_OF_STREAMThe end of stream marker.- See Also:
-
data
private final byte[] dataThe underlying data buffer. -
eod
private final int eodEnd Of Data. Similar to data.length, i.e. the last readable offset + 1. -
offset
private int offsetCurrent offset in the data buffer. -
markedOffset
private int markedOffsetThe current mark (if any).
-
-
Constructor Details
-
UnsynchronizedByteArrayInputStream
Deprecated.Constructs a new byte array input stream.- Parameters:
data- the buffer
-
UnsynchronizedByteArrayInputStream
Deprecated.Constructs a new byte array input stream.- Parameters:
data- the bufferoffset- the offset into the buffer- Throws:
IllegalArgumentException- if the offset is less than zero
-
UnsynchronizedByteArrayInputStream
Deprecated.Constructs a new byte array input stream.- Parameters:
data- the bufferoffset- the offset into the bufferlength- the length of the buffer- Throws:
IllegalArgumentException- if the offset or length less than zero
-
UnsynchronizedByteArrayInputStream
private UnsynchronizedByteArrayInputStream(byte[] data, int eod, int offset, int markedOffset)
-
-
Method Details
-
builder
Constructs a newUnsynchronizedByteArrayInputStream.Builder.- Returns:
- a new
UnsynchronizedByteArrayInputStream.Builder.
-
minPosLen
private static int minPosLen(byte[] data, int defaultValue) -
requireNonNegative
-
available
public int available()- Overrides:
availablein classInputStream
-
mark
public void mark(int readLimit) - Overrides:
markin classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
read
public int read()- Specified by:
readin classInputStream
-
read
public int read(byte[] dest) - Overrides:
readin classInputStream
-
read
public int read(byte[] dest, int off, int len) - Overrides:
readin classInputStream
-
reset
public void reset()- Overrides:
resetin classInputStream
-
skip
public long skip(long n) - Overrides:
skipin classInputStream
-
builder(),UnsynchronizedByteArrayInputStream.Builder, andUnsynchronizedByteArrayInputStream.Builder.get().