Package software.amazon.awssdk.core.io
Class ReleasableInputStream
- java.lang.Object
- 
- java.io.InputStream
- 
- java.io.FilterInputStream
- 
- software.amazon.awssdk.core.io.SdkFilterInputStream
- 
- software.amazon.awssdk.core.io.ReleasableInputStream
 
 
 
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Releasable
 - Direct Known Subclasses:
- ResettableInputStream
 
 @NotThreadSafe public class ReleasableInputStream extends SdkFilterInputStream An input stream that can have the close operation disabled (to avoid accidentally being closed). This is necessary, for example, when an input stream needs to be marked-and-reset multiple times but only as long as the input stream has not been closed. To survive not being accidentally closed, the close method can be disabled viadisableClose().The creator of this input stream should therefore always call release()in a finally block to truly release the underlying resources.- See Also:
- Releasable,- ResettableInputStream
 
- 
- 
Field Summary- 
Fields inherited from class java.io.FilterInputStreamin
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedReleasableInputStream(InputStream is)This constructor is not meant to be used directly.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()IfcloseDisabledis false, closes this input stream and releases any system resources associated with the stream.<T extends ReleasableInputStream>
 TdisableClose()Used to disable the close method.booleanisCloseDisabled()Returns true if the close method has been disabled; false otherwise.voidrelease()Closes the underlying stream file and releases any system resources associated.static ReleasableInputStreamwrap(InputStream is)Wraps the given input stream into aReleasableInputStreamif necessary.- 
Methods inherited from class software.amazon.awssdk.core.io.SdkFilterInputStreamabort, abortIfNeeded, available, mark, markSupported, read, read, reset, skip
 - 
Methods inherited from class java.io.FilterInputStreamread
 
- 
 
- 
- 
- 
Constructor Detail- 
ReleasableInputStreamprotected ReleasableInputStream(InputStream is) This constructor is not meant to be used directly. Usewrap(InputStream)instead.
 
- 
 - 
Method Detail- 
wrappublic static ReleasableInputStream wrap(InputStream is) Wraps the given input stream into aReleasableInputStreamif necessary. Note if the given input stream is aFileInputStream, aResettableInputStreamwhich is a specific subclass ofReleasableInputStreamwill be returned.
 - 
closepublic final void close() IfcloseDisabledis false, closes this input stream and releases any system resources associated with the stream. Otherwise, this method does nothing.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- SdkFilterInputStream
 
 - 
releasepublic final void release() Closes the underlying stream file and releases any system resources associated.- Specified by:
- releasein interface- Releasable
- Overrides:
- releasein class- SdkFilterInputStream
 
 - 
isCloseDisabledpublic final boolean isCloseDisabled() Returns true if the close method has been disabled; false otherwise. Once the close method is disabled, caller would be responsible to release resources viarelease().
 - 
disableClosepublic final <T extends ReleasableInputStream> T disableClose() Used to disable the close method. Once the close method is disabled, caller would be responsible to release resources viarelease().
 
- 
 
-