Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Performance improvement beyond BufferedReader & BufferedInputStream  RSS feed

 
V Chauhan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

Is there a way to improve performance of File I/O in java beyond using BufferedReaders and BufferedInputStreams?

I have to write a piece of code which searches for some string in a bunch of text and binary files. I have written this using BufferedReader for reading text files and BufferedInputStream for binary files. Typically I read these files in chunks of 64K bytes or chars of data.

This code takes approximately 10 minutes to parse around 1.5GB of data. Most of the execution time is spent in reading the files. Is there a way I can improve this performance? One option I can think of is invoking some code written in C/C++ for using JNI. I doubt even this approach will yield some significant performance improvement.

(I am using JDK1.4 and the system on which I am testing is a Windows XP box with 3 GHz processor and 1GB of RAM).

Thanks in advance for any suggestion/help.
Basu.
(edited: changed the subject and question a bit. hope to get some response this time :-) )
[ March 31, 2006: Message edited by: Basudev Agrawal ]
 
Michael Powe
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need the "new" i/o (java.nio.*), which includes memory mapping of files for faster reads/writes.

i'm on the same search myself, actually. there are plenty of "high-level" overviews of this topic but precious little detail. i need to be able to parse and process 1+ GB files in real time. ;-)

Here's a tidbit:

File Management Made Easier

thanks.

mp
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!