Package com.Ostermiller.util
Class NoCloseWriter
java.lang.Object
java.io.Writer
com.Ostermiller.util.NoCloseWriter
- All Implemented Interfaces:
NoCloseStream,Closeable,Flushable,Appendable,AutoCloseable
A writer 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 writer so that it can be passed to methods that write to 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.voidflush()voidActually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) voidvoidMethods inherited from class java.io.Writer
append, append, append, nullWriter
-
Constructor Details
-
NoCloseWriter
Protect a new writer.- Parameters:
out- The writer that is being protected.
-
-
Method Details
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Specified by:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
close
Has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException- Since:
- ostermillerutils 1.01.00
- See Also:
-
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.
-