public class InputStreamContentProvider extends Object implements ContentProvider, Callback, Closeable
ContentProvider for an InputStream.
The input stream is read once and therefore fully consumed.
Invocations to the iterator() method after the first will return an "empty" iterator
because the stream has been consumed on the first invocation.
However, it is possible for subclasses to override onRead(byte[], int, int) to copy
the content read from the stream to another location (for example a file), and be able to
support multiple invocations of iterator(), returning the iterator provided by this
class on the first invocation, and an iterator on the bytes copied to the other location
for subsequent invocations.
It is possible to specify, at the constructor, a buffer size used to read content from the stream, by default 4096 bytes.
The InputStream passed to the constructor is by default closed when is it fully
consumed (or when an exception is thrown while reading it), unless otherwise specified
to the constructor.
ContentProvider.TypedCallback.Completable, Callback.Completing, Callback.InvocableCallback, Callback.NestedInvocable.InvocationType__nonBlocking| Constructor and Description |
|---|
InputStreamContentProvider(InputStream stream) |
InputStreamContentProvider(InputStream stream,
int bufferSize) |
InputStreamContentProvider(InputStream stream,
int bufferSize,
boolean autoClose) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
failed(Throwable failure)
Callback invoked when the operation fails.
|
long |
getLength() |
Iterator<ByteBuffer> |
iterator() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisReproducibleforEach, spliteratorcombine, from, from, from, from, from, from, succeededcombine, getInvocationType, getInvocationType, invokeNonBlocking, isNonBlockingInvocationpublic InputStreamContentProvider(InputStream stream)
public InputStreamContentProvider(InputStream stream, int bufferSize)
public InputStreamContentProvider(InputStream stream, int bufferSize, boolean autoClose)
public long getLength()
getLength in interface ContentProviderpublic Iterator<ByteBuffer> iterator()
iterator in interface Iterable<ByteBuffer>public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2010 - 2020 Adobe. All Rights Reserved