Package com.Ostermiller.util
Class NoCloseOutputStream
java.lang.Object
java.io.OutputStream
com.Ostermiller.util.NoCloseOutputStream
- All Implemented Interfaces:
NoCloseStream,Closeable,Flushable,AutoCloseable
An output 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 output stream 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(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
NoCloseOutputStream
Protect a new output stream.- Parameters:
out- The output stream that is being protected.- Since:
- ostermillerutils 1.01.00
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
Has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- 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.
-