public static class Bitstream.ByteInputStream extends Object implements Bitstream.ByteStream<InputStream>
byte stream
.
Can handle input
operations only.
Constructor and Description |
---|
Bitstream.ByteInputStream(InputStream stream) |
Modifier and Type | Method and Description |
---|---|
boolean |
canInput()
Return true if stream can handle input, i.e.
|
boolean |
canOutput()
Return true if stream can handle output, i.e.
|
void |
close()
Closing the underlying stream, implies
Bitstream.ByteStream.flush() . |
void |
flush()
Synchronizes all underlying
output stream operations, or do nothing. |
InputStream |
getStream()
Returns the underlying stream
|
void |
mark(int readLimit)
Set
markpos to current position, allowing the stream to be Bitstream.ByteStream.reset() . |
long |
position()
Returns the byte position in the stream.
|
long |
position(long newPosition)
Sets this stream's position.
|
int |
read()
Reads one byte from the stream.
|
void |
reset()
Reset stream position to markpos as set via
Bitstream.ByteStream.mark(int) . |
void |
setStream(InputStream stream)
Sets the underlying stream, without
Bitstream.ByteStream.close() ing the previous one. |
long |
skip(long n)
It is implementation dependent, whether backward skip giving a negative number is supported or not.
|
int |
write(byte val)
Writes one byte, to the stream.
|
public Bitstream.ByteInputStream(InputStream stream)
public void setStream(InputStream stream)
Bitstream.ByteStream
Bitstream.ByteStream.close()
ing the previous one.setStream
in interface Bitstream.ByteStream<InputStream>
public InputStream getStream()
Bitstream.ByteStream
getStream
in interface Bitstream.ByteStream<InputStream>
public void close() throws IOException
Bitstream.ByteStream
Bitstream.ByteStream.flush()
.
Implementation will null
the stream references,
hence Bitstream.ByteStream.setStream(Object)
must be called before re-using instance.
close
in interface Bitstream.ByteStream<InputStream>
IOException
public void flush()
Bitstream.ByteStream
output stream
operations, or do nothing.flush
in interface Bitstream.ByteStream<InputStream>
public boolean canInput()
Bitstream.ByteStream
Bitstream.ByteStream.read()
.canInput
in interface Bitstream.ByteStream<InputStream>
public boolean canOutput()
Bitstream.ByteStream
Bitstream.ByteStream.write(byte)
canOutput
in interface Bitstream.ByteStream<InputStream>
public long position()
Bitstream.ByteStream
position
in interface Bitstream.ByteStream<InputStream>
public long position(long newPosition) throws UnsupportedOperationException, IllegalArgumentException
Bitstream.ByteStream
A set mark is cleared if > new position.
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the new position.
Known supporting implementation is Bitstream.ByteBufferStream
and Bitstream.ByteArrayStream
.
position
in interface Bitstream.ByteStream<InputStream>
newPosition
- The new positive position.Bitstream.EOS
if end-of-stream is reached.UnsupportedOperationException
- if not supported, i.e. Bitstream.ByteInputStream
or Bitstream.ByteOutputStream
IllegalArgumentException
- If the newPosition
is negativepublic long skip(long n) throws IOException
Bitstream.ByteStream
skip
in interface Bitstream.ByteStream<InputStream>
n
- number of bytes to skipIOException
public void mark(int readLimit)
Bitstream.ByteStream
markpos
to current position, allowing the stream to be Bitstream.ByteStream.reset()
.mark
in interface Bitstream.ByteStream<InputStream>
public void reset() throws IllegalStateException, IOException
Bitstream.ByteStream
Bitstream.ByteStream.mark(int)
.
markpos is kept, hence Bitstream.ByteStream.reset()
can be called multiple times.
reset
in interface Bitstream.ByteStream<InputStream>
IllegalStateException
- if markpos has not been set via Bitstream.ByteStream.mark(int)
or reset operation failed.IOException
- if reset operation failed.public int read() throws IOException
Bitstream.ByteStream
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the resulting value.
read
in interface Bitstream.ByteStream<InputStream>
IOException
public int write(byte val) throws UnsupportedOperationException
Bitstream.ByteStream
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the written value.
write
in interface Bitstream.ByteStream<InputStream>
UnsupportedOperationException
- if not supported, i.e. if stream is not an output stream
.