Package org.apache.hc.core5.http.io
Class EofSensorInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.hc.core5.http.io.EofSensorInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class EofSensorInputStream extends java.io.InputStreamA stream wrapper that triggers actions onclose()and EOF. Primarily used to auto-release an underlying managed connection when the response body is consumed or no longer needed.- Since:
- 4.0
- See Also:
EofSensorWatcher
-
-
Constructor Summary
Constructors Constructor Description EofSensorInputStream(java.io.InputStream in, EofSensorWatcher watcher)Creates a new EOF sensor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Aborts this stream.intavailable()voidclose()intread()intread(byte[] b)intread(byte[] b, int off, int len)
-
-
-
Constructor Detail
-
EofSensorInputStream
public EofSensorInputStream(java.io.InputStream in, EofSensorWatcher watcher)Creates a new EOF sensor. If no watcher is passed, the underlying stream will simply be closed when EOF is detected orcloseis called. Otherwise, the watcher decides whether the underlying stream should be closed before detaching from it.- Parameters:
in- the wrapped streamwatcher- the watcher for events, ornullfor auto-close behavior without notification
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
abort
public void abort() throws java.io.IOExceptionAborts this stream. This is a special version ofclose()which prevents re-use of the underlying connection, if any. Calling this method indicates that there should be no attempt to read until the end of the stream.- Throws:
java.io.IOException- in case of an IO problem on closing the underlying stream
-
-