もちろん、既存のSystem.outを「保存」して再利用するだけで済みます。
私はtxtAreaConsoleはあなたのコード内にあるかわからないが、私はちょうど次の例では "myconsoleという" を作っ://コモンズ:あなたは[ `TeeOutputStream`](httpsを使用することができます
import java.io.PrintStream;
import java.text.*;
public class Test {
public Test() {
System.setOut(new MySystemOut(System.out, new MyConsole()));
System.out.println("Hey");
}
class MyConsole {
public void appendText(String s) {
// write text somewhere else here
}
}
class MySystemOut extends PrintStream {
private final PrintStream out;
private final MyConsole txtAreaConsole;
public MySystemOut(PrintStream out, MyConsole txtAreaConsole) {
super(out);
this.out = out;
this.txtAreaConsole = txtAreaConsole;
}
@Override
public void write(int b) {
String str = String.valueOf((char) b);
txtAreaConsole.appendText(str);
out.write(b);
}
}
public static void main(String args[]) throws ParseException {
new Test();
}
}
。 [Apache Commons IO](https://commons.apache.org/proper/commons-io/)のapache.org/proper/commons-io/javadocs/api-release/index.html)を読んだり、自分で書いてくださいあなたが既に始めたように。 – Andreas
ありがとう@Andreas、まさに私が探していたもの! –