public class StreamInput extends BufferedInput
BufferedInput that reads all data from source InputStream.| Modifier and Type | Field and Description |
|---|---|
protected InputStream |
in |
buffer, EMPTY_BYTE_ARRAY, limit, markPosition, position, totalPositionBase| Constructor and Description |
|---|
StreamInput()
Creates a new stream input with default buffer size.
|
StreamInput(InputStream in)
Creates a new stream input with specified source input stream and default buffer size.
|
StreamInput(InputStream in,
int size)
Creates a new stream input with specified source input stream and buffer size.
|
StreamInput(int size)
Creates a new stream input with specified buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of bytes that can be read without blocking.
|
void |
close()
Closes the source input stream and resets this
StreamInput with
resetInput method. |
boolean |
hasAvailable()
Checks if more bytes can be read from this input.
|
boolean |
hasAvailable(int bytes)
Checks if the specified number of bytes can be read from this input.
|
int |
read(byte[] b,
int off,
int len) |
protected int |
readData()
This method is invoked when input methods need more bytes to read data.
|
void |
resetInput()
Resets this stream input by releasing source input stream and resetting position.
|
void |
rewind(long n)
Rewinds specified number of bytes.
|
void |
setInput(InputStream in)
Sets new source input stream.
|
long |
skip(long n) |
protected void |
throwEOFException()
Throws
EOFException when requested by BufferedInput.needData() method. |
checkEncapsulatedLength, checkEOB, checkRewind, mark, mark, mark, markSupported, needData, read, read, readBoolean, readByte, readByteArray, readChar, readCompactInt, readCompactLong, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readMarshalled, readMarshalled, readObject, readObject, readObject, readProperties, readShort, readToByteBuffer, readToDataOutput, readToOutputStream, readUnsignedByte, readUnsignedShort, readUTF, readUTFBody, readUTFChar, readUTFString, reset, seek, skipBytes, totalPosition, unmarkprotected InputStream in
public StreamInput()
public StreamInput(int size)
size - the initial buffer sizeIllegalArgumentException - if size is not positivepublic StreamInput(InputStream in)
in - the source to read frompublic StreamInput(InputStream in, int size)
in - the source to read fromsize - the initial buffer sizeIllegalArgumentException - if size is not positivepublic void setInput(InputStream in)
null to release source.in - the source to read frompublic void resetInput()
public void close()
throws IOException
StreamInput with
resetInput method.close in interface Closeableclose in interface ObjectInputclose in interface AutoCloseableclose in class InputStreamIOException - if an I/O error occurs.public boolean hasAvailable()
throws IOException
available() > 0 check.
This implementation returns
hasAvailable(1)hasAvailable in class BufferedInputtrue if more bytes can be read from this input.IOException - if an I/O error occurs.public boolean hasAvailable(int bytes)
throws IOException
available() >= bytes check.
This implementation returns
available() >= byteshasAvailable in class BufferedInputbytes - the number of bytes.true if the specified number of bytes can be read from this input.IOException - if an I/O error occurs.public int available()
throws IOException
available in interface ObjectInputavailable in class BufferedInputIOException - If an I/O error has occurred.public int read(byte[] b,
int off,
int len)
throws IOException
read in interface ObjectInputread in class BufferedInputIOExceptionpublic long skip(long n)
throws IOException
skip in interface ObjectInputskip in class BufferedInputIOExceptionpublic void rewind(long n)
rewind in class BufferedInputn - the number of bytes to rewindprotected int readData()
throws IOException
-1
if no bytes can be read because the end of the stream has been reached.
This method may block if needed.
This method is allowed to update buffer, position, limit and totalPositionBase fields as needed.
This method shall never throw an EOFException.
readData in class BufferedInput-1 if there is no more data because the end of the stream has been reachedIOException - if an I/O error occursprotected void throwEOFException()
throws EOFException
BufferedInputEOFException when requested by BufferedInput.needData() method.
This implementation throws same reused instance with truncated stack trace to avoid garbage.throwEOFException in class BufferedInputEOFExceptionCopyright © 2002–2025 Devexperts LLC. All rights reserved.