Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.logging
Class MaskingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by 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

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
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.io.FilterOutputStream
flush, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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
Method Detail

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()

Release 0.1 (2008-07-10_1838)