Package com.Ostermiller.util
Class NoCloseReader
java.lang.Object
java.io.Reader
com.Ostermiller.util.NoCloseReader
- All Implemented Interfaces:
NoCloseStream,Closeable,AutoCloseable,Readable
A reader which 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 reader 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 TypeMethodDescriptionvoidclose()Has no effect.voidmark(int readlimit) booleanintread()intread(char[] cbuf) intread(char[] cbuf, int off, int len) booleanready()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.Reader
nullReader, read, transferTo
-
Constructor Details
-
NoCloseReader
Protect a new reader.- Parameters:
in- The reader that is being protected.- Since:
- ostermillerutils 1.01.00
-
-
Method Details
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin classReader- Throws:
IOException
-
skip
- Overrides:
skipin classReader- Throws:
IOException
-
ready
- Overrides:
readyin classReader- Throws:
IOException
-
close
Has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException- Since:
- ostermillerutils 1.01.00
- See Also:
-
mark
- Overrides:
markin classReader- Throws:
IOException
-
reset
- Overrides:
resetin classReader- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classReader
-
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.
-