org.yajul.io
Class EchoInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.yajul.io.EchoInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class EchoInputStream
- extends java.io.FilterInputStream
An input stream that echoes all data read from the input stream into
an output stream. This can be useful for debugging.
- Author:
- josh
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary |
EchoInputStream(java.io.InputStream in,
java.io.OutputStream out)
Creates new EchoInputStream that writes everything read from
'in' into 'out'. |
Method Summary |
int |
read()
Reads the next byte in the input stream, and also writes it to
the echo output stream. |
int |
read(byte[] bytes,
int off,
int len)
Reads the specified number of bytes from the input stream and also
writes them to the echo output stream. |
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EchoInputStream
public EchoInputStream(java.io.InputStream in,
java.io.OutputStream out)
- Creates new EchoInputStream that writes everything read from
'in' into 'out'.
- Parameters:
in
- The underlying input stream.out
- The output stream to echo the input to.
read
public int read()
throws java.io.IOException
- Reads the next byte in the input stream, and also writes it to
the echo output stream.
- Overrides:
read
in class java.io.FilterInputStream
- Returns:
- int - The next byte, or -1 for end of file.
- Throws:
java.io.IOException
- if there was a problem reading from the underlying
stream or writing to the echo stream.- See Also:
FilterInputStream.read()
read
public int read(byte[] bytes,
int off,
int len)
throws java.io.IOException
- Reads the specified number of bytes from the input stream and also
writes them to the echo output stream.
- Overrides:
read
in class java.io.FilterInputStream
- Parameters:
bytes
- The array where the bytes read from the input will
be placed.off
- Offset for the first byte.len
- The number of bytes to read.
- Returns:
- int The number of bytes actually read, or -1 for end of file.
- Throws:
java.io.IOException
- if there was a problem reading from the underlying
stream or writing to the echo stream.- See Also:
FilterInputStream.read(byte[],int,int)
Copyright © 2008. All Rights Reserved.