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 protected static final byte[] NO_DATA = new byte[0];
28
29
30 private InputStream in;
31
32
33 public BufferedServletInputStream() {
34 this.in = new ByteArrayInputStream( NO_DATA );
35 }
36
37 public BufferedServletInputStream(InputStream in) {
38 this.in = in;
39 }
40
41 public BufferedServletInputStream(String text) {
42 in = new ByteArrayInputStream( text.getBytes() );
43 }
44
45 public BufferedServletInputStream(byte[] data) {
46 in = new ByteArrayInputStream(data);
47 }
48
49
50
51
52 public int available() throws IOException {
53 return in.available();
54 }
55
56 public void close() throws IOException {
57 in.close();
58 }
59
60 public void mark(int readlimit) {
61 in.mark(readlimit);
62 }
63
64 public boolean markSupported() {
65 return in.markSupported();
66 }
67
68 public int read(byte[] b) throws IOException {
69 return in.read(b);
70 }
71
72 public int read(byte[] b, int off, int len) throws IOException {
73 return in.read(b, off, len);
74 }
75
76 public int read() throws IOException {
77 return in.read();
78 }
79
80 public void reset() throws IOException {
81 in.reset();
82 }
83
84 public long skip(long n) throws IOException {
85 return in.skip(n);
86 }
87 }