KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > common > commands > ResultBufferedCommand


1 package org.objectweb.celtix.common.commands;
2
3 import java.io.*;
4
5 public class ResultBufferedCommand extends ForkedCommand {
6
7     private ByteArrayOutputStream bosOut;
8     private ByteArrayOutputStream bosError;
9
10     public ResultBufferedCommand() {
11         init();
12     }
13
14     public ResultBufferedCommand(String JavaDoc[] 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
46 }
47
Popular Tags