• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the best way to write to a file?

 
Robert Popular
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am creating a batch process that will be configured as a chron-job on a Solaris machine. I have never attempted this before and it needs to be capturing it's activities in a log file that is enabled for appending.
I was going to try to use a pre-written library of log4j classes, but they have been extended beyond what I really need here, so it is not really an option unless I go just plain log4j (without the addded funct.) The thing is I have never used log4j.
I have been told to keep it very basic which to me is to use the FileOutputStream and write to a file. But will this file take a relative path to the filname.log or will it have to be explicit? If it has to be explicit, is the best way to account for a change in the location is to use a ResourceBundle with a properties file that the user can modify? Does the path to the ResourceBundle prop file have to be explicit as well?
Thanks in advance!
bp
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a relative path.
BTW, when writing textual content, you should use a Writer instead of an OutputStream.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic