| 1 | package dolda.bsvc; |
| 2 | |
| 3 | import java.io.*; |
| 4 | |
| 5 | public class Console implements bsh.ConsoleInterface { |
| 6 | ByteArrayOutputStream obuf = new ByteArrayOutputStream(); |
| 7 | ByteArrayOutputStream ebuf = new ByteArrayOutputStream(); |
| 8 | Reader in = new StringReader(""); |
| 9 | PrintStream out; |
| 10 | PrintStream err; |
| 11 | { |
| 12 | try { |
| 13 | out = new PrintStream(obuf, false, "UTF-8"); |
| 14 | err = new PrintStream(ebuf, false, "UTF-8"); |
| 15 | } catch(UnsupportedEncodingException e) { |
| 16 | throw(new Error(e)); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | public void error(Object msg) { |
| 21 | getErr().println(msg); |
| 22 | } |
| 23 | |
| 24 | public void print(Object o) { |
| 25 | getOut().print(o); |
| 26 | } |
| 27 | |
| 28 | public void println(Object o) { |
| 29 | getOut().println(o); |
| 30 | } |
| 31 | |
| 32 | public PrintStream getOut() { |
| 33 | return(out); |
| 34 | } |
| 35 | |
| 36 | public PrintStream getErr() { |
| 37 | return(err); |
| 38 | } |
| 39 | |
| 40 | public Reader getIn() { |
| 41 | return(in); |
| 42 | } |
| 43 | |
| 44 | public void reset() { |
| 45 | obuf.reset(); |
| 46 | ebuf.reset(); |
| 47 | } |
| 48 | } |