source: josm/trunk/src/org/tukaani/xz/CloseIgnoringInputStream.java@ 15851

Last change on this file since 15851 was 13350, checked in by stoecker, 7 years ago

see #15816 - add XZ support

File size: 1.4 KB
Line 
1/*
2 * CloseIgnoringInputStream
3 *
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
5 *
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
8 */
9
10package org.tukaani.xz;
11
12import java.io.InputStream;
13import java.io.FilterInputStream;
14
15/**
16 * An {@code InputStream} wrapper whose {@code close()} does nothing.
17 * This is useful with raw decompressors if you want to call
18 * {@code close()} to release memory allocated from an {@link ArrayCache}
19 * but don't want to close the underlying {@code InputStream}.
20 * For example:
21 * <p><blockquote><pre>
22 * InputStream rawdec = new LZMA2InputStream(
23 * new CloseIgnoringInputStream(myInputStream),
24 * myDictSize, null, myArrayCache);
25 * doSomething(rawdec);
26 * rawdec.close(); // This doesn't close myInputStream.
27 * </pre></blockquote>
28 * <p>
29 * With {@link XZInputStream}, {@link SingleXZInputStream}, and
30 * {@link SeekableXZInputStream} you can use their {@code close(boolean)}
31 * method to avoid closing the underlying {@code InputStream}; with
32 * those classes {@code CloseIgnoringInputStream} isn't needed.
33 *
34 * @since 1.7
35 */
36public class CloseIgnoringInputStream extends FilterInputStream {
37 /**
38 * Creates a new {@code CloseIgnoringInputStream}.
39 */
40 public CloseIgnoringInputStream(InputStream in) {
41 super(in);
42 }
43
44 /**
45 * This does nothing (doesn't call {@code in.close()}).
46 */
47 public void close() {}
48}
Note: See TracBrowser for help on using the repository browser.