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:
- java.io.Closeable
public class DetachableInputStream
- extends java.io.FilterInputStream
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).
Fields inherited from class java.io.FilterInputStream |
in |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DetachableInputStream
public DetachableInputStream(java.io.InputStream in)
length
public long length()
throws java.io.IOException
- Returns:
- count of bytes read
- Throws:
java.io.IOException
detach
public void detach()
throws java.io.IOException
- 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:
java.io.IOException
available
public int available()
throws java.io.IOException
- Overrides:
available
in class java.io.FilterInputStream
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.FilterInputStream
- Throws:
java.io.IOException
markSupported
public boolean markSupported()
- Overrides:
markSupported
in class java.io.FilterInputStream
mark
public void mark(int readlimit)
- Overrides:
mark
in class java.io.FilterInputStream
read
public int read()
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b)
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
reset
public void reset()
throws java.io.IOException
- Overrides:
reset
in class java.io.FilterInputStream
- Throws:
java.io.IOException
skip
public long skip(long n)
throws java.io.IOException
- Overrides:
skip
in class java.io.FilterInputStream
- Throws:
java.io.IOException
Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.