• Post Reply Bookmark Topic Watch Topic
  • New Topic

write a file in java (but not with FileWriter)  RSS feed

 
Ronan Dowd
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'd like to have my java program (Java 1.5) write to a text file but I don't want to use the java.io.FileWriter class
(as my rational analyser indicates that I should avoid doing this, but it doesn't say why I shouldn't nor does it
suggest an alternatives)
Currently I have as below:
FileWriter output = new FileWriter("myFile.txt", false);
output.write("some info I will write");

output.flush();
output.close();

Any suggestions on how to do this without using FileWriter, i.e. a way which work in any locale.
Thanks - Ro.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say the first step should be to understand why the analyzer doesn't like the class - there's nothing wrong with FileWriter in general. Maybe it's just unhappy that the code uses the platform default encoding, and is thus not cross-platform compatible?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!