• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading large data

 
Kalai Selvan
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to read large amount of data (5 Lakh lines of data) from a file within a time limit of 1 Sec. I tried to use buffered reader, but it is taking more than 9 Sec. Is there any other efficient api available in java for reading large amount of data?

Thanks in advance.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously reading from a file is constrained by hardware, so the answer is probably to get faster hardware.
Using streams will probably be faster than using a reader because readers do codepage conversion. Of course, you lose that convenient readLine() method.
RandomAccessFile has a readLine() method, but it doesn't support the full Unicode charset. I don't know if it's faster.
The "new" IO classes may offer other options. For the most part, they introduce functionality which was not available in the "old" io classes and the old io classes actually use NIO under the covers, so performance may or may not be better.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!