• Post Reply Bookmark Topic Watch Topic
  • New Topic

What's the best way to write to a file.  RSS feed

 
Malith Yapa
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya folks,
Well i was wondering what would be the best way to write out to a text file.
I tried the DataOutputStream and the writeUTF() method( Since none of the other methods are working) But i keep getting two unwanted bites at the beggining of the file. I want the file to be 100% accurate. Got any tips. Why won't the write() methods work? Thanks fellas. Cheers
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. If its a simple text file you could do something like...



Alterntively, you could use a random access file if you want to continually append an existing file...



The API will tell you how to skip to the end of the file etc to manipulate it as well as perform other functions on it, so look there!

Cheers
[ April 16, 2007: Message edited by: Sam Bluesman ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!