【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/本回答被网友采纳