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, markLimit, markPosition, position, totalPositionBase
Constructor and Description |
---|
StreamInput()
Creates a new stream input with default buffer capacity.
|
StreamInput(InputStream in)
Creates a new stream input with specified source input stream and default buffer capacity.
|
StreamInput(InputStream in,
int size)
Creates a new stream input with specified source input stream and buffer capacity.
|
StreamInput(int size)
Creates a new stream input with specified buffer capacity.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
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. |
checkEOB, checkRewind, mark, mark, markSupported, needData, read, read, readBoolean, readByte, readByteArray, readChar, readCompactInt, readCompactLong, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTFChar, readUTFString, reset, seek, skipBytes, totalPosition
protected 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
close
in interface Closeable
close
in interface ObjectInput
close
in interface AutoCloseable
close
in class InputStream
IOException
public int available() throws IOException
available
in interface ObjectInput
available
in class BufferedInput
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in interface ObjectInput
read
in class BufferedInput
IOException
public long skip(long n) throws IOException
skip
in interface ObjectInput
skip
in class BufferedInput
IOException
public void rewind(long n)
BufferedInput
rewind
in class BufferedInput
n
- the number of bytes to rewindprotected int readData() throws IOException
BufferedInput
-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
BufferedInput
EOFException
when requested by BufferedInput.needData()
method.
This implementation throws same reused instance with truncated stack trace to avoid garbage.throwEOFException
in class BufferedInput
EOFException
Copyright © 2014 Devexperts. All Rights Reserved.