I found the code below from the internet, works but it doesn\'t write the printed console to omt.txt, it only writes the System.out.println statements after the
In System.java, this is the declaration of the out property:
public final static PrintStream out
You'll see that it can only be one PrintSteam object at a time. So it's either the console or the file, but not both.
At this line, you have effectively re-channelled the destination:
System.setOut(ps);
So your output stops displaying on the console.