blob: 5a72607366f4f1e0b5f7cd667db5764f6857f090 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package cgeo.geocaching.files;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* Filter input stream that doesn't forward close() calls. Needed to parse multiple XML documents by SAX XML parser from
* one input stream (e.g. ZipInputStream) because SAX parser closes stream.
*/
public class NoCloseInputStream extends FilterInputStream {
private static ClosedInputStream closedInputStream = new ClosedInputStream();
public NoCloseInputStream(InputStream in) {
super(in);
}
@Override
public void close() throws IOException {
in = closedInputStream;
}
private static class ClosedInputStream extends InputStream {
@Override
public int read() throws IOException {
throw new IOException("Stream already closed.");
}
}
}
|