com.Ostermiller.util Java Utilities


com.Ostermiller.util
Class NoCloseOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.Ostermiller.util.NoCloseOutputStream
All Implemented Interfaces:
NoCloseStream, Closeable, Flushable

public class NoCloseOutputStream
extends OutputStream
implements NoCloseStream

An output stream with a close method with no effect. More information about this class is available from ostermiller.org.

This class is designed 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 http://ostermiller.org/contact.pl?regarding=Java+Utilities

Constructor Summary
NoCloseOutputStream(OutputStream out)
          Protect a new output stream.
 
Method Summary
 void close()
          Has no effect.
 void flush()
          
 void reallyClose()
          Actually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.
 void write(byte[] b)
          
 void write(byte[] b, int off, int len)
          
 void write(int b)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoCloseOutputStream

public NoCloseOutputStream(OutputStream out)
Protect a new output stream.

Parameters:
out - The output stream that is being protected.
Since:
ostermillerutils 1.01.00
Method Detail

write

public void write(int b)
           throws IOException

Specified by:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException

Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException

Overrides:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Has no effect.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException
Since:
ostermillerutils 1.01.00
See Also:
reallyClose()

reallyClose

public void reallyClose()
                 throws IOException
Actually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.

Specified by:
reallyClose in interface NoCloseStream
Throws:
IOException - if an I/O error occurs.

com.Ostermiller.util Java Utilities


Copyright © 2001-2012 by Stephen Ostermiller