Package org.apache.axiom.om.util
Class DetachableInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.axiom.om.util.DetachableInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
FilterInputStream that delegates to the original
InputStream. When detach() is called, the original
InputStream is consumed, and closed. The unread bytes are
stored in a local stream.
Subsequent requests are serviced by the local stream.
Rationale: The detached stream can be closed and its
resources freed, but the consumer of the stream can
continue to receive data.
Cons: If there are a lot of bytes remaining, these are
buffered. Currently they are buffered incore (this
could be improved to buffer in a file).
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
DetachableInputStream
-
-
Method Details
-
length
- Returns:
- count of bytes read
- Throws:
IOException
-
detach
Consume the input stream and close it. The bytes in the input stream are buffered. (Thus the original input stream can release its resources, but the consumer of the stream can still receive data).- Throws:
IOException
-
available
- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classFilterInputStream
-
mark
public void mark(int readlimit) - Overrides:
markin classFilterInputStream
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-