How do you get the output of a Java program in a text file instead of getting it on the console?

pratheesh k p

You can get the output into a file instead of the console / command prompt as follows:

System.setOut(new PrintStream(new FileOutputStream("Test.txt")));
System.out.println("Hello How r u");
Now the output Hello How r u will be printed to file instead of command prompt.

In addition, you can also redirect I/O to a file like java aaa > aaa.txt

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact