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
InputStream wrapped around a single ByteBuffer.- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()booleanbooleanisClosed()voidmark(int nReadlimit) booleanintread()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, skipNBytes, transferTo
-
Constructor Details
-
ByteBufferInputStream
Constructor- Parameters:
aBuffer-ByteBufferto use. May not benull.
-
-
Method Details
-
isClosed
public boolean isClosed() -
getBuffer
- Returns:
- The contained
ByteBuffer. Handle with care! May benullif the stream is closed!
-
isAnythingAvailable
public boolean isAnythingAvailable() -
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.
-