• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Undo redirect to file

 
Kaustubha Raut
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have used the following code to redirect the output to a file, but I am not able to find how to undo this and direct stdout back to console in later part of the program.
How do I set the System.setout() to print to console again?

Thanks.

 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Store a reference to System.out before you change it initially, then change it back:
This means that you will need to store it somewhere of course, probably as an instance field or something similar.
 
Kaustubha Raut
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob,
It works.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic