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
@NotThreadSafe public final class ByteBuffersInputStream extends InputStream
InputStreamwrapped around one or moreByteBufferobjects.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description ByteBuffersInputStream(ByteBuffer... aBuffers)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()ByteBuffer[]getAllBuffers()longgetAvailable()booleanisAnythingAvailable()booleanisClosed()voidmark(int nReadlimit)booleanmarkSupported()intread()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, transferTo
-
-
-
-
Constructor Detail
-
ByteBuffersInputStream
public ByteBuffersInputStream(@Nonnull @Nonempty ByteBuffer... aBuffers)
Constructor- Parameters:
aBuffers- Array ofByteBuffer. May neither benullnor empty and may not containnullelements.
-
-
Method Detail
-
isClosed
public boolean isClosed()
-
getAllBuffers
@Nonnull @ReturnsMutableCopy public ByteBuffer[] 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(@Nonnull byte[] aBuf)
- Overrides:
readin classInputStream
-
read
public int read(@Nonnull byte[] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen)
- Overrides:
readin classInputStream
-
skip
@Nonnegative public long skip(long nBytesToSkip)
- Overrides:
skipin classInputStream
-
read
@Nonnegative public long read(@Nonnull ByteBuffer aDestByteBuffer)
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.
-
-