01: package org.antlr.runtime;
02:
03: import java.io.*;
04:
05: /** A kind of ReaderStream that pulls from an InputStream.
06: * Useful for reading from stdin and specifying file encodings etc...
07: */
08: public class ANTLRInputStream extends ANTLRReaderStream {
09: public ANTLRInputStream() {
10: }
11:
12: public ANTLRInputStream(InputStream input) throws IOException {
13: this (input, null);
14: }
15:
16: public ANTLRInputStream(InputStream input, int size)
17: throws IOException {
18: this (input, size, null);
19: }
20:
21: public ANTLRInputStream(InputStream input, String encoding)
22: throws IOException {
23: this (input, INITIAL_BUFFER_SIZE, encoding);
24: }
25:
26: public ANTLRInputStream(InputStream input, int size, String encoding)
27: throws IOException {
28: this (input, size, READ_BUFFER_SIZE, encoding);
29: }
30:
31: public ANTLRInputStream(InputStream input, int size,
32: int readBufferSize, String encoding) throws IOException {
33: InputStreamReader isr;
34: if (encoding != null) {
35: isr = new InputStreamReader(input, encoding);
36: } else {
37: isr = new InputStreamReader(input);
38: }
39: load(isr, size, readBufferSize);
40: }
41: }
|