Package io.deephaven.io.streams
Class ByteBufferInputStream
java.lang.Object
java.io.InputStream
io.deephaven.io.streams.ByteBufferInputStream
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
This is an InputStream implementation which reads from a java.nio.ByteBuffer. If a read operation crosses the end of
the buffer, the BufferUnderflowException is converted to an EOFException.
The stream contains no state other than that in in the buffer itself, so the buffer can be exchanged at will with the
setBuffer() method.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct a new stream which reads from a byte buffer/ -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) void
read
(ByteBuffer dest, int length) boolean
byte
readByte()
char
readChar()
double
float
void
readFully
(byte[] b) void
readFully
(byte[] b, int off, int len) int
readInt()
readLine()
long
readLong()
short
int
int
readUTF()
void
readUTF
(@NotNull CharSequenceAdapterBuilder output) readUTF
(@NotNull CharSequenceAdapterBuilder output, @NotNull StringCache<String> cache) void
reset()
void
setBuffer
(ByteBuffer buf) Set the buffer to be used for future read operations.long
skip
(long n) int
skipBytes
(int n) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
buf
the buffer from which we read
-
-
Constructor Details
-
ByteBufferInputStream
Construct a new stream which reads from a byte buffer/
-
-
Method Details
-
setBuffer
Set the buffer to be used for future read operations. -
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
skipBytes
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readLine
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readUTF
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
readUTF
public String readUTF(@NotNull @NotNull CharSequenceAdapterBuilder output, @NotNull @NotNull StringCache<String> cache) throws IOException - Throws:
IOException
-
readUTF
- Throws:
IOException
-
read
-