|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.kirkwarez.kirkpack.io.Streamer
The Streamer
is avery simple class that reads from one stream, and
writes to another, the size of the buffer at a time, until the providing stream runs
out of data, or the optionally specified length parameter has been reached.
Due to an annoying coincidence, the stream method that streams for a length using
the default buffersize does not exist. You can circumvent this by using the stream
method that does length and supplying the DEFAULT_BUFFER_SIZE
as
buffersize. Sorry :^P
Field Summary | |
static int |
DEFAULT_BUFFER_SIZE
The default buffer size. |
protected InputStream |
input
The stream to read from. |
protected OutputStream |
output
The stream to write to. |
Constructor Summary | |
Streamer(InputStream input,
OutputStream output)
Constructs new Streamer that will read from the given input and
write it to the given output. |
Method Summary | |
InputStream |
getInputStream()
Returns the input stream. |
OutputStream |
getOutputStream()
Returns the output stream. |
protected byte[] |
read(int buffersize)
Fully reads in the buffer from the input stream, unless the end of the stream is reached. |
protected void |
setInputStream(InputStream input)
Sets the input stream. |
protected void |
setOutputStream(OutputStream output)
Sets the output stream. |
void |
stream()
Streams one stream to another using the default buffer size. |
void |
stream(int buffersize)
Streams one stream to another using the given buffer size. |
void |
stream(int buffersize,
int length)
Streams one stream to another using the given buffer size for the given amount of bytes. |
protected void |
write(byte[] buffer)
Fully writes out the given buffer to the output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected InputStream input
protected OutputStream output
public static final int DEFAULT_BUFFER_SIZE
Constructor Detail |
public Streamer(InputStream input, OutputStream output)
Streamer
that will read from the given input and
write it to the given output.
input
- The stream to read from. May not be null.output
- The stream to write to. May not be null.Method Detail |
public void stream(int buffersize, int length) throws IOException
buffersize
- The size of the buffer to use.length
- The amount of bytes to stream over.
IOException
- When the streams mess up, or when there is not enough data.public void stream(int buffersize) throws IOException
buffersize
- The size of the buffer to use.
IOException
- When the streams mess up.public void stream() throws IOException
IOException
- When the streams mess up.protected byte[] read(int buffersize) throws IOException
buffersize
- the amount to read in.
IOException
- When there is trouble reading.protected void write(byte[] buffer) throws IOException
buffer
- The buffer to write to the output stream.
IOException
- When there is trouble writing.public InputStream getInputStream()
protected void setInputStream(InputStream input)
input
- The stream which will be read from.public OutputStream getOutputStream()
protected void setOutputStream(OutputStream output)
output
- The stream which will be written to.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |