Package com.helger.base.io.stream
Class MultiByteBufferInputStream
java.lang.Object
java.io.InputStream
com.helger.base.io.stream.MultiByteBufferInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
InputStream wrapped around one or more
ByteBuffer objects.- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionMultiByteBufferInputStream(@NonNull @Nonempty ByteBuffer... aBuffers) Constructor -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()@NonNull ByteBuffer[]longbooleanbooleanisClosed()voidmark(int nReadlimit) booleanintread()intread(byte @NonNull [] aBuf) intread(byte @NonNull [] aBuf, int nOfs, int nLen) longread(@NonNull ByteBuffer aDestByteBuffer) Reads as much as possible into the destination buffer.voidreset()longskip(long nBytesToSkip) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
MultiByteBufferInputStream
Constructor- Parameters:
aBuffers- Array ofByteBuffer. May neither benullnor empty and may not containnullelements.
-
-
Method Details
-
isClosed
public boolean isClosed()- Returns:
trueif this stream has been closed,falseotherwise.
-
getAllBuffers
- Returns:
- A copy of the array with the byte buffers. Never
null.
-
isAnythingAvailable
public boolean isAnythingAvailable()- Returns:
trueif any byte buffer has at least one byte left.
-
getAvailable
@Nonnegative public long getAvailable()- Returns:
- The number of available bytes as a long. Always ≥ 0.
-
available
@Nonnegative public int available()- Overrides:
availablein classInputStream
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
mark
public void mark(int nReadlimit) - Overrides:
markin classInputStream
-
reset
public void reset()- Overrides:
resetin classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
read
public int read()- Specified by:
readin classInputStream
-
read
public int read(byte @NonNull [] aBuf) - Overrides:
readin classInputStream
-
read
public int read(byte @NonNull [] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen) - Overrides:
readin classInputStream
-
skip
@Nonnegative public long skip(long nBytesToSkip) - Overrides:
skipin classInputStream
-
read
Reads as much as possible into the destination buffer.- Parameters:
aDestByteBuffer- The destination byte buffer to use. May not benull.- Returns:
- The number of bytes read. Always ≥ 0.
-