1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.apache.commons.messagelet.impl; |
11 | |
|
12 | |
import java.io.ByteArrayInputStream; |
13 | |
import java.io.IOException; |
14 | |
import java.io.InputStream; |
15 | |
|
16 | |
import javax.servlet.ServletInputStream; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class BufferedServletInputStream extends ServletInputStream { |
26 | |
|
27 | 0 | protected static final byte[] NO_DATA = new byte[0]; |
28 | |
|
29 | |
|
30 | |
private InputStream in; |
31 | |
|
32 | |
|
33 | 0 | public BufferedServletInputStream() { |
34 | 0 | this.in = new ByteArrayInputStream( NO_DATA ); |
35 | 0 | } |
36 | |
|
37 | 0 | public BufferedServletInputStream(InputStream in) { |
38 | 0 | this.in = in; |
39 | 0 | } |
40 | |
|
41 | 0 | public BufferedServletInputStream(String text) { |
42 | 0 | in = new ByteArrayInputStream( text.getBytes() ); |
43 | 0 | } |
44 | |
|
45 | 0 | public BufferedServletInputStream(byte[] data) { |
46 | 0 | in = new ByteArrayInputStream(data); |
47 | 0 | } |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public int available() throws IOException { |
53 | 0 | return in.available(); |
54 | |
} |
55 | |
|
56 | |
public void close() throws IOException { |
57 | 0 | in.close(); |
58 | 0 | } |
59 | |
|
60 | |
public void mark(int readlimit) { |
61 | 0 | in.mark(readlimit); |
62 | 0 | } |
63 | |
|
64 | |
public boolean markSupported() { |
65 | 0 | return in.markSupported(); |
66 | |
} |
67 | |
|
68 | |
public int read(byte[] b) throws IOException { |
69 | 0 | return in.read(b); |
70 | |
} |
71 | |
|
72 | |
public int read(byte[] b, int off, int len) throws IOException { |
73 | 0 | return in.read(b, off, len); |
74 | |
} |
75 | |
|
76 | |
public int read() throws IOException { |
77 | 0 | return in.read(); |
78 | |
} |
79 | |
|
80 | |
public void reset() throws IOException { |
81 | 0 | in.reset(); |
82 | 0 | } |
83 | |
|
84 | |
public long skip(long n) throws IOException { |
85 | 0 | return in.skip(n); |
86 | |
} |
87 | |
} |