I'm wondering if I can let java write all console output in a txt file without disabling it on console
PrintStream o = new PrintStream(new File("A.txt"));
PrintStream console = System.out;
System.setOut(o);
System.setOut(console);
so I need both command be excecuted
I couldn't comment because of my reputation. But the answer below will solve your question : System.out to string