Class CloseIgnoringInputStream

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

    public class CloseIgnoringInputStream
    extends java.io.FilterInputStream
    An InputStream wrapper whose close() does nothing. This is useful with raw decompressors if you want to call close() to release memory allocated from an ArrayCache but don't want to close the underlying InputStream. For example:

     InputStream rawdec = new LZMA2InputStream(
             new CloseIgnoringInputStream(myInputStream),
             myDictSize, null, myArrayCache);
     doSomething(rawdec);
     rawdec.close(); // This doesn't close myInputStream.
     

    With XZInputStream, SingleXZInputStream, and SeekableXZInputStream you can use their close(boolean) method to avoid closing the underlying InputStream; with those classes CloseIgnoringInputStream isn't needed.

    Since:
    1.7
    • Field Summary

      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      CloseIgnoringInputStream​(java.io.InputStream in)
      Creates a new CloseIgnoringInputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      This does nothing (doesn't call in.close()).
      • Methods inherited from class java.io.FilterInputStream

        available, mark, markSupported, read, read, read, reset, skip
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

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

      • CloseIgnoringInputStream

        public CloseIgnoringInputStream​(java.io.InputStream in)
        Creates a new CloseIgnoringInputStream.
    • Method Detail

      • close

        public void close()
        This does nothing (doesn't call in.close()).
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterInputStream