Package com.helger.commons.io.stream
Class ByteBuffersInputStream
java.lang.Object
java.io.InputStream
com.helger.commons.io.stream.ByteBuffersInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
InputStream wrapped around one or more
ByteBuffer objects.- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()longbooleanbooleanisClosed()voidmark(int nReadlimit) booleanintread()intread(byte[] aBuf) intread(byte[] aBuf, int nOfs, int nLen) longread(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
-
ByteBuffersInputStream
Constructor- Parameters:
aBuffers- Array ofByteBuffer. May neither benullnor empty and may not containnullelements.
-
-
Method Details
-
isClosed
public boolean isClosed() -
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
- Returns:
- The number of available bytes as a long. Always ≥ 0.
-
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
- Overrides:
readin classInputStream
-
read
- Overrides:
readin classInputStream
-
skip
- 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.
-