edu.emory.mathcs.util.io
Class TeeInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
edu.emory.mathcs.util.io.TeeInputStream
- public class TeeInputStream
- extends java.io.FilterInputStream
Filter input stream that - in addition to normal processing - writes a copy
of the data, as it is being read, to a specified output stream. Allows for
basic splitting of an input stream. Name comes from Unix command "tee"
which has similar applications.
- Version:
- 1.0
- Author:
- Dawid Kurzyniec
- See Also:
ForkOutputStream
,
RedirectingInputStream
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary |
TeeInputStream(java.io.InputStream in,
java.io.OutputStream tee)
Creates a new tee input stream that reads from a specified input and
sends a copy to a specified output. |
TeeInputStream(java.io.InputStream in,
java.io.OutputStream tee,
boolean autoFlush,
boolean autoClose)
Creates a new tee input stream that reads from a specified input, sends
a copy to a specified output, and has specified flushing and closing
policy. |
TeeInputStream(java.io.InputStream in,
java.io.OutputStream tee,
boolean autoFlush,
boolean autoClose,
boolean bestEffort)
Creates a new tee input stream that reads from a specified input, sends
a copy to a specified output, and has specified flushing and closing
policy. |
Method Summary |
void |
close()
|
int |
read()
|
int |
read(byte[] buf,
int off,
int len)
|
Methods inherited from class java.io.FilterInputStream |
available, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TeeInputStream
public TeeInputStream(java.io.InputStream in,
java.io.OutputStream tee)
- Creates a new tee input stream that reads from a specified input and
sends a copy to a specified output. The tee output will be flushed after
each read from the input. EOF in the input will not cause closing of the
tee output. IOExceptions when writing to tee (e.g. if tee is closed)
are propagated.
- Parameters:
in
- the input to read fromtee
- the output to send copy to
TeeInputStream
public TeeInputStream(java.io.InputStream in,
java.io.OutputStream tee,
boolean autoFlush,
boolean autoClose)
- Creates a new tee input stream that reads from a specified input, sends
a copy to a specified output, and has specified flushing and closing
policy. The autoFlush parameter decides whether the tee output should be
automatically flushed after every read from the input. The autoClose
parameter decides whether the output should be closed upon EOF from
the input. IOExceptions when writing to tee (e.g. if tee is closed)
are propagated.
- Parameters:
in
- the input to read fromtee
- the output to send copy toautoFlush
- decides whether to flush tee output after each readautoClose
- decides whether to close tee output upon EOF on input
TeeInputStream
public TeeInputStream(java.io.InputStream in,
java.io.OutputStream tee,
boolean autoFlush,
boolean autoClose,
boolean bestEffort)
- Creates a new tee input stream that reads from a specified input, sends
a copy to a specified output, and has specified flushing and closing
policy. The autoFlush parameter decides whether the tee output should be
automatically flushed after every read from the input. The autoClose
parameter decides whether the output should be closed upon EOF from
the input. The bestEffort parameter decides whether IOExceptions when
writing to tee (e.g. if tee is closed) should be propagated.
- Parameters:
in
- the input to read fromtee
- the output to send copy toautoFlush
- decides whether to flush tee output after each readautoClose
- decides whether to close tee output upon EOF on inputbestEffort
- if true, ignores IOExceptions on the tee (e.g. if tee
is closed)
read
public int read()
throws java.io.IOException
- Throws:
java.io.IOException
read
public int read(byte[] buf,
int off,
int len)
throws java.io.IOException
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Throws:
java.io.IOException