org.cloudfoundry.client.lib.io
Class DynamicInputStream
java.lang.Object
java.io.InputStream
org.cloudfoundry.client.lib.io.DynamicInputStream
- All Implemented Interfaces:
- Closeable
- Direct Known Subclasses:
- DynamicZipInputStream
public abstract class DynamicInputStream
- extends InputStream
InputStream that dynamically loads data on demand as the stream is read. Subclasses must implement the
writeMoreData()
method.
- Author:
- Phillip Webb
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DynamicInputStream
public DynamicInputStream()
read
public int read()
throws IOException
- Specified by:
read
in class InputStream
- Throws:
IOException
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Overrides:
read
in class InputStream
- Throws:
IOException
getOutputStream
protected final OutputStream getOutputStream()
- Returns the
OutputStream
that should be used when writing
data. The output
stream instance will not change during the life of the object and so can be used as the source to a a
FilterInputStream
. This is an in-memory stream so care should be taken to not write large amounts of
data.
- Returns:
- the output stream
- See Also:
writeMoreData()
writeMoreData
protected abstract boolean writeMoreData()
throws IOException
- Called when more data should be written to the
output stream
. This method can be
called many times, implementations should write zero or more bytes to output stream
on
each call. Generally it is recommended that not more that 4096 bytes are written in a single call.
- Returns:
- false when no more data is available to write.
- Throws:
IOException
Copyright © 2013. All rights reserved.