public class InputStreamWrapper
extends java.io.InputStream
InputStream which accesses a contained
Stream instance. This allows classes that use the standard Java
I/O features (in package java.io.*) to transparently use
a P2J stream instead. That stream may be on a remote node.| Modifier and Type | Field and Description |
|---|---|
private long |
mark
The marked position in the stream.
|
private static int |
READ_CHUNK_SIZE
The chunk to read at once from the remote
stream, via in the read(byte[], int, int)
implementation. |
private Stream |
stream
The contained stream that does our real work.
|
| Constructor and Description |
|---|
InputStreamWrapper(Stream stream)
Construct an instance which wrappers the given stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Obtains an estimate of the number of bytes that can be read from this
stream without blocking.
|
void |
close()
Closes the input stream and releases OS resources associated with it.
|
Stream |
getStream()
Get the wrapped FWD stream.
|
void |
mark(int readlimit)
Mark the current position in the stream.
|
boolean |
markSupported()
Tests if this stream supports the mark mode.
|
int |
read()
Reads the next byte of data from the input stream.
|
int |
read(byte[] array,
int off,
int len)
Read a chunk of bytes from the current read position in the stream to the
offset calculated by given length or to the
EOF, whichever
comes first. |
void |
reset()
Reset the stream to the marked position.
|
private static final int READ_CHUNK_SIZE
stream, via in the read(byte[], int, int)
implementation.private Stream stream
private long mark
public InputStreamWrapper(Stream stream)
stream - The P2J stream to wrap.public int read()
throws java.io.IOException
int, the actual value will always be
between 0 and 255 inclusive. When the end of the stream has been reached,
-1 is returned.
The underlying stream subclass determines the content of the result. Byte oriented streams such as pipes or files will return a byte while streams that generate keystrokes or characters may return a DBCS or Unicode character. Any data that is greater in size than a byte will be truncated!
This method blocks waiting for the data, the end of the stream or some exceptional condition.
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] array,
int off,
int len)
throws java.io.IOException
EOF, whichever
comes first. The EOF character is not returned.read in class java.io.InputStreamarray - The array in which to save bytes.off - The offset into the array at which to start saving bytes.len - The maximum number of bytes to read.EOF has been
reached). The number of bytes read will be the smaller
of the len parameter or the actual bytes left
before the EOF.java.io.IOException - If an I/O error occurs.public int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreampublic void mark(int readlimit)
mark in class java.io.InputStreamreadlimit - This argument is not used.public void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionpublic boolean markSupported()
markSupported in class java.io.InputStreamtrue.