• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing to System.out or a file  RSS feed

 
Chris McGuire
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method that does reporting of statistics. I need to be able to have it write to either System.out or to a file, based upon the object passed to it. I would imagine this could be done using outputstreams, but I don't know how to do it.
Thanks to anyone who can provide any assistance.
Chris
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,
Welcome to JavaRanch!
Just make your method look like this:

Then you can call it like

or like

Easy!
 
Chris McGuire
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Ernest!
Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!