Java如何把控制台上的数据显示在GUI界面

如题所述

【Listing 1:用管道流截取控制台输出】
PipedInputStream pipedIS = new PipedInputStream();
PipedOutputStream pipedOS = new PipedOutputStream();
try {
pipedOS.connect(pipedIS);
}
catch(IOException e) {
System.err.println("连接失败");
System.exit(1);
}
PrintStream ps = new PrintStream(pipedOS);
System.setOut(ps);
System.setErr(ps);

ps对象就是你需要的了
详见 http://www.ibm.com/developerworks/cn/java/l-console/
温馨提示:内容为网友见解,仅供参考
第1个回答  2015-06-29
【Listing 1:用管道流截取控制台输出】
PipedInputStream pipedIS = new PipedInputStream();
PipedOutputStream pipedOS = new PipedOutputStream();
try {
pipedOS.connect(pipedIS);
}
catch(IOException e) {
System.err.println("连接失败");
System.exit(1);
}
PrintStream ps = new PrintStream(pipedOS);
System.setOut(ps);
System.setErr(ps);

ps对象就是你需要的了
详见 http://www.ibm.com/developerworks/cn/java/l-console/本回答被网友采纳
相似回答