Package org.apache.commons.io.input
Class UnsynchronizedByteArrayInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.io.input.UnsynchronizedByteArrayInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class UnsynchronizedByteArrayInputStream extends java.io.InputStreamThis is an alternative toByteArrayInputStreamwhich 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:
UnsynchronizedByteArrayInputStream.Builder,ByteArrayInputStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUnsynchronizedByteArrayInputStream.BuilderBuilds a newUnsynchronizedByteArrayInputStream.
-
Field Summary
Fields Modifier and Type Field Description private byte[]dataThe underlying data buffer.static intEND_OF_STREAMThe end of stream marker.private inteodEnd Of Data.private intmarkedOffsetThe current mark (if any).private intoffsetCurrent offset in the data buffer.
-
Constructor Summary
Constructors Modifier Constructor Description UnsynchronizedByteArrayInputStream(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()static UnsynchronizedByteArrayInputStream.Builderbuilder()Constructs a newUnsynchronizedByteArrayInputStream.Builder.voidmark(int readLimit)booleanmarkSupported()private static intminPosLen(byte[] data, int defaultValue)intread()intread(byte[] dest)intread(byte[] dest, int off, int len)private static intrequireNonNegative(int value, java.lang.String name)voidreset()longskip(long n)
-
-
-
Field Detail
-
END_OF_STREAM
public static final int END_OF_STREAM
The end of stream marker.- See Also:
- Constant Field Values
-
data
private final byte[] data
The underlying data buffer.
-
eod
private final int eod
End Of Data. Similar to data.length, which is the last readable offset + 1.
-
offset
private int offset
Current offset in the data buffer.
-
markedOffset
private int markedOffset
The current mark (if any).
-
-
Constructor Detail
-
UnsynchronizedByteArrayInputStream
@Deprecated public UnsynchronizedByteArrayInputStream(byte[] data)
Deprecated.Constructs a new byte array input stream.- Parameters:
data- the buffer
-
UnsynchronizedByteArrayInputStream
@Deprecated public UnsynchronizedByteArrayInputStream(byte[] data, int offset)Deprecated.Constructs a new byte array input stream.- Parameters:
data- the bufferoffset- the offset into the buffer- Throws:
java.lang.IllegalArgumentException- if the offset is less than zero
-
UnsynchronizedByteArrayInputStream
@Deprecated public UnsynchronizedByteArrayInputStream(byte[] data, int offset, int length)Deprecated.Constructs a new byte array input stream.- Parameters:
data- the bufferoffset- the offset into the bufferlength- the length of the buffer- Throws:
java.lang.IllegalArgumentException- if the offset or length less than zero
-
UnsynchronizedByteArrayInputStream
private UnsynchronizedByteArrayInputStream(byte[] data, int eod, int offset, int markedOffset)
-
-
Method Detail
-
builder
public static UnsynchronizedByteArrayInputStream.Builder builder()
Constructs a newUnsynchronizedByteArrayInputStream.Builder.- Returns:
- a new
UnsynchronizedByteArrayInputStream.Builder.
-
minPosLen
private static int minPosLen(byte[] data, int defaultValue)
-
requireNonNegative
private static int requireNonNegative(int value, java.lang.String name)
-
available
public int available()
- Overrides:
availablein classjava.io.InputStream
-
mark
public void mark(int readLimit)
- Overrides:
markin classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
read
public int read()
- Specified by:
readin classjava.io.InputStream
-
read
public int read(byte[] dest)
- Overrides:
readin classjava.io.InputStream
-
read
public int read(byte[] dest, int off, int len)- Overrides:
readin classjava.io.InputStream
-
reset
public void reset()
- Overrides:
resetin classjava.io.InputStream
-
skip
public long skip(long n)
- Overrides:
skipin classjava.io.InputStream
-
-