|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
edu.rice.cs.plt.io.DirectInputStream
public abstract class DirectInputStream
An InputStream that supports reading directly into an OutputStream. This class
provides default implementations defined in terms of InputStream and OutputStream
methods. Subclasses can override (at least) readAll(OutputStream, byte[]) and
read(OutputStream, int, byte[]) to provide better implementations (by, for example,
not invoking InputStream.read(byte[])).
Also guarantees that, consistent with the Reader class, all read operations are
by default defined in terms of the (declared abstract) read(byte[], int, int) method.
DirectReader,
DirectOutputStream,
DirectWriter| Field Summary | |
|---|---|
protected static int |
DEFAULT_BUFFER_SIZE
|
| Constructor Summary | |
|---|---|
DirectInputStream()
|
|
| Method Summary | |
|---|---|
int |
read()
Delegate to the more general read(byte[], int, int) method |
int |
read(byte[] bbuf)
Delegate to the more general read(byte[], int, int) method |
abstract int |
read(byte[] bbuf,
int offset,
int bytes)
Subclasses are, at a minimum, required to implement this method. |
int |
read(OutputStream out,
int bytes)
Read some number of bytes from this stream, sending them to the provided OutputStream. |
int |
read(OutputStream out,
int bytes,
byte[] buffer)
Read some number of bytes from this stream, sending them to the provided OutputStream. |
int |
read(OutputStream out,
int bytes,
int bufferSize)
Read some number of bytes from this stream, sending them to the provided OutputStream. |
int |
readAll(OutputStream out)
Read the full contents of this stream, sending the bytes to the provided OutputStream. |
int |
readAll(OutputStream out,
byte[] buffer)
Read the full contents of this stream, sending the bytes to the provided OutputStream. |
int |
readAll(OutputStream out,
int bufferSize)
Read the full contents of this stream, sending the bytes to the provided OutputStream. |
| Methods inherited from class java.io.InputStream |
|---|
available, close, mark, markSupported, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int DEFAULT_BUFFER_SIZE
| Constructor Detail |
|---|
public DirectInputStream()
| Method Detail |
|---|
public int read()
throws IOException
read(byte[], int, int) method
read in class InputStreamIOException
public int read(byte[] bbuf)
throws IOException
read(byte[], int, int) method
read in class InputStreamIOException
public abstract int read(byte[] bbuf,
int offset,
int bytes)
throws IOException
read in class InputStreamIOException
public int read(OutputStream out,
int bytes)
throws IOException
OutputStream.
The default implementation invokes read(OutputStream, int, int) with the minimum of
bytes and DEFAULT_BUFFER_SIZE. Subclasses that know the size of this stream's
remaining contents, or that do not rely on a buffer in read(OutputStream, int, byte[]),
should override this method.
out - A stream to be written tobytes - The number of bytes to read
-1 if this stream is at the end of file; otherwise, the number of bytes read
IOException - If an error occurs during reading or writing
public int read(OutputStream out,
int bytes,
int bufferSize)
throws IOException
OutputStream.
The default implementation invokes read(OutputStream, int, byte[]) with a newly-allocated array
of the given size. Subclasses that do not rely on a buffer in read(OutputStream, int, byte[])
should override this method.
out - A stream to be written tobytes - The number of bytes to readbufferSize - The size of buffer to use (if necessary). Smaller values may reduce the amount of
memory required; larger values may increase performance of large streams
-1 if this stream is at the end of file; otherwise, the number of bytes read
IOException - If an error occurs during reading or writing
IllegalArgumentException - If bufferSize <= 0
public int read(OutputStream out,
int bytes,
byte[] buffer)
throws IOException
OutputStream.
The given buffer is useful in repeated read invocations to avoid unnecessary
memory allocation. The default implementation repeatedly fills the given buffer via a
InputStream.read(byte[], int, int) operation, then writes it via
OutputStream.write(byte[], int, int). Subclasses that do not require an external buffer
should override this method.
out - A stream to be written tobytes - The number of bytes to readbuffer - A buffer used to copy bytes from this stream to the output stream. Note that this is only
used to avoid unnecessary memory allocation. No assumptions are made about the buffer's
contents (which may be overwritten), and no assumptions should be made about the contents
of the buffer after the method invocation.
-1 if this stream is at the end of file; otherwise, the number of bytes read
IOException - If an error occurs during reading or writing
IllegalArgumentException - If buffer has size 0
public int readAll(OutputStream out)
throws IOException
OutputStream.
The method will block until an end-of-file is reached. The default implementation invokes
readAll(OutputStream, int) with DEFAULT_BUFFER_SIZE. Subclasses that know the
size of this stream's remaining contents, or that do not rely on a buffer in
readAll(OutputStream, byte[]), should override this method.
out - A stream to be written to
-1 if this stream is at the end of file; otherwise, the number of bytes read
(or, if the number is too large, Integer.MAX_VALUE)
IOException - If an error occurs during reading or writing
public int readAll(OutputStream out,
int bufferSize)
throws IOException
OutputStream.
The method will block until an end-of-file is reached. The default implementation invokes
readAll(OutputStream, byte[]) with a newly-allocated array of the given size. Subclasses
that do not rely on a buffer in readAll(OutputStream, byte[]) should override this method.
out - A stream to be written tobufferSize - The size of buffer to use (if necessary). Smaller values may reduce the amount of
memory required; larger values may increase performance of large streams
-1 if this stream is at the end of file; otherwise, the number of bytes read
(or, if the number is too large, Integer.MAX_VALUE)
IOException - If an error occurs during reading or writing
IllegalArgumentException - If bufferSize <= 0
public int readAll(OutputStream out,
byte[] buffer)
throws IOException
OutputStream.
The given buffer is useful in repeated readAll invocations to avoid unnecessary
memory allocation. The method will block until an end-of-file is reached. The default
implementation repeatedly fills the given buffer via a InputStream.read(byte[]) operation,
then writes it via OutputStream.write(byte[]). Subclasses that do not require an external buffer
should override this method.
out - A stream to be written tobuffer - A buffer used to copy bytes from this stream to the output stream. Note that this is only
used to avoid unnecessary memory allocation. No assumptions are made about the buffer's
contents (which may be overwritten), and no assumptions should be made about the contents
of the buffer after the method invocation.
-1 if this stream is at the end of file; otherwise, the number of bytes read
(or, if the number is too large, Integer.MAX_VALUE)
IOException - If an error occurs during reading or writing
IllegalArgumentException - If buffer has size 0
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||