• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to redirect the output into a file.

 
cake naiyou
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a program, I currently have



This generally output the object "process" to the screen in a XML format.

But I want to redirect this XML format into a saved file, like test.XML. How to do that in java? Thanks.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you replace that line with something that passes a FileOutputStream (possibly wrapped in a PrintStream) to process()?

Other possibilities are using a redirect (>) from the command line or redefining sysout in your program with System.setOut().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!