org.apache.commons.httpclient
Class AutoCloseInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--org.apache.commons.httpclient.AutoCloseInputStream
- class AutoCloseInputStream
- extends FilterInputStream
Closes an underlying stream as soon as the end of the stream is reached, and
notifies a client when it has done so.
- Since:
- 2.0
- Author:
- Ortwin Gl?ck, Eric Johnson, Mike Bowler
Method Summary |
void |
close()
Close the stream, and also close the underlying stream if it is not
already closed. |
int |
read()
Reads the next byte of data from the input stream. |
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the
buffer array b. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the stream. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AutoCloseInputStream
public AutoCloseInputStream(InputStream in,
ResponseConsumedWatcher watcher)
- Create a new auto closing stream for the provided connection
- Parameters:
in
- the input stream to read fromwatcher
- To be notified when the contents of the stream have been
consumed.
read
public int read()
throws IOException
- Reads the next byte of data from the input stream.
- Overrides:
read
in class FilterInputStream
- Returns:
- the character read, or -1 for EOF
- Throws:
IOException
- when there is an error reading
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Reads up to
len
bytes of data from the stream.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- a byte
array to read data intooff
- an offset within the array to store datalen
- the maximum number of bytes to read- Returns:
- the number of bytes read or -1 for EOF
- Throws:
IOException
- if there are errors reading
read
public int read(byte[] b)
throws IOException
- Reads some number of bytes from the input stream and stores them into the
buffer array b.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- a byte
array to read data into- Returns:
- the number of bytes read or -1 for EOF
- Throws:
IOException
- if there are errors reading
close
public void close()
throws IOException
- Close the stream, and also close the underlying stream if it is not
already closed.
- Overrides:
close
in class FilterInputStream
- Throws:
IOException
- If an IO problem occurs.
Copyright © 2001-2004 Apache Software Foundation. All Rights Reserved.