Package com.Ostermiller.util
Class NoCloseInputStream
java.lang.Object
java.io.InputStream
com.Ostermiller.util.NoCloseInputStream
- All Implemented Interfaces:
NoCloseStream,Closeable,AutoCloseable
An input stream with a close method with no effect.
More information about this class is available from ostermiller.org.
This class implements the Decorator design pattern to wrap a normal input stream so that it can be passed to methods that read from it and may erroneously close it. This class is a workaround when the method cannot be modified because it is in a library.
- Since:
- ostermillerutils 1.01.00
- Author:
- Stephen Ostermiller https://ostermiller.org/contact.pl?regarding=Java+Utilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Has no effect.voidmark(int readlimit) booleanintread()intread(byte[] b) intread(byte[] b, int off, int len) voidActually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.voidreset()longskip(long n) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
NoCloseInputStream
Protect a new input stream.- Parameters:
in- The input stream that is being protected.- Since:
- ostermillerutils 1.01.00
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
Has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- Since:
- ostermillerutils 1.01.00
- See Also:
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
reallyClose
Actually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.- Specified by:
reallyClosein interfaceNoCloseStream- Throws:
IOException- if an I/O error occurs.
-