Class NoCloseOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class NoCloseOutputStream
    extends java.io.FilterOutputStream
    A Wrapper stream that does never calls close on its parent. This implementation is needed when creating ZipOutputStream, as the final ZipDirectory is written when close is called on the ZipOutputSteam.
    Author:
    Thomas Morgner
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      NoCloseOutputStream​(java.io.OutputStream out)
      Create a new NoCloseOutputStream with the given output stream a parent.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this output stream and releases any system resources associated with the stream, but does not close the underlying output stream.
      • Methods inherited from class java.io.FilterOutputStream

        flush, write, write, write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NoCloseOutputStream

        public NoCloseOutputStream​(java.io.OutputStream out)
        Create a new NoCloseOutputStream with the given output stream a parent.
        Parameters:
        out - the parent stream
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Closes this output stream and releases any system resources associated with the stream, but does not close the underlying output stream.

        The close method of FilterOutputStream calls its flush method.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterOutputStream
        Throws:
        java.io.IOException - if an I/O error occurs.
        See Also:
        FilterOutputStream.flush(), FilterOutputStream.out