I want to save all the text on the terminal as a output on a text file. For the output there can be a function to be used instead of System.out.println()
class OutSave
{
String output;
public static void main()
{
output="";
print("Print this");
print("And save this");
}
public static print(String p)
{
output=output+"\n"+p;
System.out.println(p);
}
}
Something like this but I cannot figure this out for the inputs supplied by the user.
Thanks in Advance
Here is a simple example of how to write a log file of what you are printing.
Edit: Log user input (ints)
You could call this code from a method then change the running boolean to exit the loop when you are done as this will hang your program in the input loop if you do not exit. Might be a good idea to thread this too.