This is in a method which I call with the pathName and Text as arguments. My problem is that once this method has executed once, the output doesn't get redirected to console. Now I figure I have to use System.setOut(); again... but what do I put between the parenthesis to get the text displayed on console?? :geek:
Question
Maniac1181
Hey guys!
I found a way to redirect the outputs from a java program to a text file. I do it this way.
try{
FileOutputStream out = new FileOutputStream("pathName",true);
System.setOut(new PrintStream(out,true));
System.out.println("Text");
out.close();
}
catch(java.io.IOException e) {e.printStackTrace();}
This is in a method which I call with the pathName and Text as arguments. My problem is that once this method has executed once, the output doesn't get redirected to console. Now I figure I have to use System.setOut(); again... but what do I put between the parenthesis to get the text displayed on console?? :geek:
Link to comment
Share on other sites
1 answer to this question
Recommended Posts