Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Recycling my piped streams for file output?  RSS feed

 
Rilto Rilto
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I have a question regarding streams.

Ive looked high and low on the net, and havent really solved it via this route so im posting.

I have a system whereby I am saving all System.out + System.err messages to a console. This works fine.

I.e.




I need now to physically save this stuff to disk, so as well as having a consol window this data needs to be written to a file.

Logically it would be nice to tap one of these pipes and use the data going through them to be written to a file. Could any one point me in the direction of a resource or suggest how this could be tackled?

The bottom of this page http://home.tiscali.nl/~bmc88/java/sbook/029.html suggests something like what im thinking, but I dont know how to fully implement it.

Thanks
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not uncommon to write a "tee" class which takes one input and produces several outputs. However, in the interest of saving yourself writing and maintaining custom code and making your code more accessible to others you will probably want to look at the Java Logging API, which allows you to configure destination and amount of output of your program without recompiling.
 
Rilto Rilto
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks, ive never heard of it. Ill read up.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!