public abstract class AbstractNonFinalizableFileInputStream
extends org.apache.commons.io.input.ProxyInputStream
InputStream instances returned by connectors which operate over a FileSystem.
It's a ProxyInputStream which also contains the concept of a PathLock which is released when the stream is
closed or fully consumed. Also has the functionality of AutoCloseInputStream but without the Object.finalize()
implementation.
Because in most implementations the actual reading of the stream requires initialising/maintaining a connection, instances are
created through a LazyStreamSupplier. This allows such connection/resource to be provisioned lazily. This is very
useful in cases such as FileSystem.list(FileConnectorConfig, String, boolean, Predicate). Being able to only lazily
establish the connections, prevents the connector from opening many connections at the same time, at the risk that many of them
might end up not being necessary at the same time.
in| Constructor and Description |
|---|
AbstractNonFinalizableFileInputStream(LazyStreamSupplier streamSupplier,
Lock lock) |
AbstractNonFinalizableFileInputStream(LazyStreamSupplier streamSupplier,
PathLock lock) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterRead(int n)
Automatically closes the stream if the end of stream was reached.
|
void |
close()
Closes the stream and invokes
Lock.release() on the lock. |
protected void |
doClose() |
boolean |
isLocked() |
public AbstractNonFinalizableFileInputStream(LazyStreamSupplier streamSupplier, PathLock lock)
public AbstractNonFinalizableFileInputStream(LazyStreamSupplier streamSupplier, Lock lock)
protected void afterRead(int n)
throws IOException
afterRead in class org.apache.commons.io.input.ProxyInputStreamn - number of bytes read, or -1 if no more bytes are availableIOException - if the stream could not be closedpublic final void close()
throws IOException
Lock.release() on the lock.
Because the actual stream is lazily opened, the possibility exists for this method being invoked before the
streamSupplier is used. In such case, this method will not fail.
close in interface Closeableclose in interface AutoCloseableclose in class org.apache.commons.io.input.ProxyInputStreamIOException - in case of errorprotected void doClose()
throws IOException
IOExceptionpublic boolean isLocked()
Copyright © 2003–2019 MuleSoft, Inc.. All rights reserved.