FIM.Util
Class CopyFilterInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--FIM.Util.CopyFilterInputStream
- public class CopyFilterInputStream
- extends FilterInputStream
A stream which copies all data sent through it to another stream. The content itself is not touched in any way.
If bytes are skipped, they will NOT be copied to the output. If mark
and reset
is used,
the double read bytes will be copied twice.
- Version:
- 1.0, 12.9.2001
- Author:
- Michael Sonntag
Method Summary |
void |
close()
Closes the source and the copy stream. |
int |
read()
Reads the next byte of data from this input stream. |
int |
read(byte[] b)
Reads up to byte.length bytes of data from this input stream into an array of bytes.
|
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this input stream into an array of bytes. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CopyFilterInputStream
public CopyFilterInputStream(InputStream in,
OutputStream copy)
- Create a new stream to copy the content read through to another stream.
- Parameters:
out
- the underlying OutputStream
close
public void close()
throws IOException
- Closes the source and the copy stream.
- Overrides:
close
in class FilterInputStream
- Throws:
IOException
- if an exception occurred in the underlying stream (either the source or the copy)
read
public int read()
throws IOException
- Reads the next byte of data from this input stream. The value byte is returned as an int in the range
0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.
This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
- Overrides:
read
in class FilterInputStream
- Returns:
- the next byte of data, or -1 if the end of the stream is reached
- Throws:
IOException
- if an exception occurred in the underlying stream (either the source or the copy)
read
public int read(byte[] b)
throws IOException
- Reads up to
byte.length
bytes of data from this input stream into an array of bytes.
This method blocks until some input is available.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- the buffer into which the data is read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the
end of the stream has been reached
- Throws:
IOException
- if an exception occurred in the underlying stream (either the source or the copy)
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Reads up to len bytes of data from this input stream into an array of bytes. This method blocks
until some input is available.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the
end of the stream has been reached
- Throws:
IOException
- if an exception occurred in the underlying stream (either the source or the copy)
Submit a bug
Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.