Package com.helger.commons.io.stream
Class ByteBufferInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.helger.commons.io.stream.ByteBufferInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@NotThreadSafe public final class ByteBufferInputStream extends InputStream
InputStreamwrapped around a singleByteBuffer.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description ByteBufferInputStream(ByteBuffer aBuffer)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()ByteBuffergetBuffer()booleanisAnythingAvailable()booleanisClosed()voidmark(int nReadlimit)booleanmarkSupported()intread()intread(byte[] aBuf)intread(byte[] aBuffer, 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
-
ByteBufferInputStream
public ByteBufferInputStream(@Nonnull ByteBuffer aBuffer)
Constructor- Parameters:
aBuffer-ByteBufferto use. May not benull.
-
-
Method Detail
-
isClosed
public boolean isClosed()
-
getBuffer
@Nullable public ByteBuffer getBuffer()
- Returns:
- The contained
ByteBuffer. Handle with care! May benullif the stream is closed!
-
isAnythingAvailable
public boolean isAnythingAvailable()
-
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[] aBuffer, @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.
-
-