de.lmu.ifi.dbs.elki.logging
Class MaskingOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
de.lmu.ifi.dbs.elki.logging.MaskingOutputStream
- All Implemented Interfaces:
- Closeable, Flushable
public class MaskingOutputStream
- extends FilterOutputStream
An OutputStream to mask the underlying OutputStream.
MaskingOutputStream behaves exactly like a FilterOutputStream
except in closing. A call of the close()
method will not close the underlying
OutputStream, but free the reference to it.
Thus, setting System.err
or System.out
as
underlying OutputStream does not put those System OutputStreams
at risk of being closed.
- Author:
- Arthur Zimek
Constructor Summary |
MaskingOutputStream(OutputStream out)
Keeps the given OutputStream as underlying OutputStream,
passing calls to the underlying OutputStream,
but preventing it from being closed. |
Method Summary |
void |
close()
Closes this output stream and releases any system resources
associated with the stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MaskingOutputStream
public MaskingOutputStream(OutputStream out)
- Keeps the given OutputStream as underlying OutputStream,
passing calls to the underlying OutputStream,
but preventing it from being closed.
- Parameters:
out
- an OutputStream to pass methodcalls to
close
public void close()
throws IOException
- Closes this output stream and releases any system resources
associated with the stream.
The close
method of MaskingOutputStream
calls the flush()
method of
FilterOutputStream
, and then sets
its underlying output stream to null
.
Thus any subsequent calls of methods to this OutputStream
will result in a NullPointerException.
- Specified by:
close
in interface Closeable
- Overrides:
close
in class FilterOutputStream
- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.flush()