1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.javadpkg.io.impl;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23
24 import net.sourceforge.javadpkg.io.CloseHandler;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class UncloseableInputStream extends InputStream {
40
41
42
43 private InputStream in;
44
45 private CloseHandler closeHandler;
46
47
48
49
50
51
52
53
54
55
56
57
58 public UncloseableInputStream(InputStream in) {
59 super();
60
61 if (in == null)
62 throw new IllegalArgumentException("Argument in is null.");
63
64 this.in = in;
65 this.closeHandler = null;
66 }
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 public UncloseableInputStream(InputStream in, CloseHandler closeHandler) {
83 super();
84
85 if (in == null)
86 throw new IllegalArgumentException("Argument in is null.");
87 if (closeHandler == null)
88 throw new IllegalArgumentException("Argument closeHandler is null.");
89
90 this.in = in;
91 this.closeHandler = closeHandler;
92 }
93
94
95 @Override
96 public int read() throws IOException {
97 return this.in.read();
98 }
99
100
101 @Override
102 public int read(byte[] b) throws IOException {
103 return this.in.read(b);
104 }
105
106
107 @Override
108 public int read(byte[] b, int off, int len) throws IOException {
109 return this.in.read(b, off, len);
110 }
111
112
113 @Override
114 public long skip(long n) throws IOException {
115 return this.in.skip(n);
116 }
117
118
119 @Override
120 public int available() throws IOException {
121 return this.in.available();
122 }
123
124
125 @Override
126 public void close() throws IOException {
127 if (this.closeHandler != null)
128 this.closeHandler.closed();
129 }
130
131
132 @Override
133 public synchronized void mark(int readlimit) {
134 this.in.mark(readlimit);
135 }
136
137
138 @Override
139 public synchronized void reset() throws IOException {
140 this.in.reset();
141 }
142
143
144 @Override
145 public boolean markSupported() {
146 return this.in.markSupported();
147 }
148
149
150 }