01: /*
02: * Created on 20-Mar-2006
03: */
04: package uk.org.ponder.streamutil.read;
05:
06: import java.io.Reader;
07:
08: import uk.org.ponder.streamutil.StreamCloseUtil;
09: import uk.org.ponder.util.UniversalRuntimeException;
10:
11: public class ReaderRIS implements ReadInputStream {
12:
13: private Reader reader;
14: boolean eof = false;
15:
16: public ReaderRIS(Reader reader) {
17: this .reader = reader;
18: }
19:
20: public char get() {
21: try {
22: int read = reader.read();
23: if (read == -1) {
24: eof = true;
25: }
26: return (char) read;
27: } catch (Exception e) {
28: throw UniversalRuntimeException.accumulate(e,
29: "Error reading from Reader ");
30: }
31: }
32:
33: public int read(char[] target, int start, int length) {
34: try {
35: return reader.read(target, start, length);
36: } catch (Exception e) {
37: throw UniversalRuntimeException.accumulate(e,
38: "Error reading from Reader ");
39: }
40: }
41:
42: public boolean EOF() {
43: return eof;
44: }
45:
46: public void close() {
47: StreamCloseUtil.closeReader(reader);
48: }
49: }
|