aspose file tools*
The moose likes Java in General and the fly likes What is the best way to write to a file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is the best way to write to a file?" Watch "What is the best way to write to a file?" New topic
Author

What is the best way to write to a file?

Robert Popular
Greenhorn

Joined: Oct 14, 2002
Posts: 6
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

Joined: Jul 11, 2001
Posts: 14112
You can use a relative path.
BTW, when writing textual content, you should use a Writer instead of an OutputStream.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
 
subject: What is the best way to write to a file?