• Post Reply Bookmark Topic Watch Topic
  • New Topic

Efficient way of writing to file

 
Manu Ramakrishnan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a batch process that writes an output of 155 MB file to disk. When I observed the progress, it looks like it takes 10 minutes to write first 10 MB, about 20 minutes for the next 10 MB and so on. I used
Writer out = new PrintWriter(new BufferedWriter(new File Writer(fileName)), true);//true for auto flush
out.write(String);

Is this the most efficient way of writing or is it better to split the output to different files and merge all the files at the end? Are there more efficient ways of writing to file? I need suggestions.
Thanks
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can write a 188 meg file in around 20 seconds with a Pentium 4 1.8Ghz, so I'd say your problem is probably your batch process. Are you maxing out the CPU or RAM? Check your task manager or run top and see if your process or others running on the same machine are hogging resources. Tweaking your java code won't do a thing unless you have the hardware to run it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!