• Post Reply Bookmark Topic Watch Topic
  • New Topic

Performance with File Output  RSS feed

 
Ken Pullin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I was wondering if anyone had any comments on performance issues related to writing data to a file. Currenctly, I'm performing the task like this:
File f = new File("test.txt");
File Writer fs = new FileWriter(f);
fw.write("This is a test");
I would like to hear comments about whether or not this is good from a perfomance standpoint or is their additional ways that are more efficient than this. Thanks, Ken
 
jayakeshpk
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would rather use byte stream to do the same because in case if the text you want to write is too large or if the text is coming from another part of the program writing it this way can be little slow.
If you open the file using a
FileInputStream f=new FileInputStream("hxkhh.txt");
f.write(char);
it will be character wise reading.
This way if you are expecting the data from the network or
for that matter any other source you can read it byte byte and do
not have to wait for the whole text and probably improve the
perfprmance
Bye
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add a BufferedWriter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!