01: package org.objectweb.celtix.common.commands;
02:
03: import java.io.*;
04:
05: public class ResultBufferedCommand extends ForkedCommand {
06:
07: private ByteArrayOutputStream bosOut;
08: private ByteArrayOutputStream bosError;
09:
10: public ResultBufferedCommand() {
11: init();
12: }
13:
14: public ResultBufferedCommand(String[] args) {
15: super (args);
16: init();
17: }
18:
19: public InputStream getOutput() {
20: return new ByteArrayInputStream(this .bosOut.toByteArray());
21: }
22:
23: public BufferedReader getBufferedOutputReader() {
24: return new BufferedReader(new InputStreamReader(
25: new ByteArrayInputStream(this .bosOut.toByteArray())));
26: }
27:
28: public InputStream getError() {
29: return new ByteArrayInputStream(bosError.toByteArray());
30: }
31:
32: public BufferedReader getBufferedErrorReader() {
33: return new BufferedReader(new InputStreamReader(
34: new ByteArrayInputStream(bosError.toByteArray())));
35: }
36:
37: private void init() {
38: bosOut = new ByteArrayOutputStream();
39: bosError = new ByteArrayOutputStream();
40:
41: setOutputStream(new PrintStream(bosOut));
42: setErrorStream(new PrintStream(bosError));
43: }
44:
45: }
|