@NotThreadSafe public class ReleasableInputStream extends SdkFilterInputStream implements Releasable
ReleasableInputStream.disableClose()
.
The creator of this input stream should therefore always call
ReleasableInputStream.release()
in a finally block to truly release the underlying
resources.
Releasable
,
ResettableInputStream
in
Modifier | Constructor and Description |
---|---|
protected |
ReleasableInputStream(InputStream is)
This constructor is not meant to be used directly.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
If
ReleasableInputStream.closeDisabled is false, closes this input stream and releases
any system resources associated with the stream. |
<T extends ReleasableInputStream> |
disableClose()
Used to disable the close method.
|
boolean |
isCloseDisabled()
Returns true if the close method has been disabled; false otherwise.
|
void |
release()
Closes the underlying stream file and releases any system resources associated.
|
static ReleasableInputStream |
wrap(InputStream is)
Wraps the given input stream into a
ReleasableInputStream if
necessary. |
abort, abortIfNeeded, available, getDelegateStream, isAborted, isMetricActivated, mark, markSupported, read, read, reset, skip
read
protected ReleasableInputStream(InputStream is)
ReleasableInputStream.wrap(InputStream)
instead.public final void close()
ReleasableInputStream.closeDisabled
is false, closes this input stream and releases
any system resources associated with the stream. Otherwise, this method
does nothing.close
in interface Closeable
close
in interface AutoCloseable
close
in class SdkFilterInputStream
public final void release()
release
in interface Releasable
release
in class SdkFilterInputStream
public final boolean isCloseDisabled()
ReleasableInputStream.release()
.public final <T extends ReleasableInputStream> T disableClose()
ReleasableInputStream.release()
.public static ReleasableInputStream wrap(InputStream is)
ReleasableInputStream
if
necessary. Note if the given input stream is a FileInputStream
, a
ResettableInputStream
which is a specific subclass of
ReleasableInputStream
will be returned.Copyright © 2024. All rights reserved.