A BufferedReader is probably the best you can do. No matter what your code does, when you come right down to it the code has to read each of the bytes in the file. So expect the time taken to read the file to be proportional to the file's size.
Joined: Aug 11, 2006
I read in one of the mail thread that if we use BufferedReader to read large files,the performance will be slowdown since temporarily the data will be strored in the String pool. So is it ok if I use BufferedReader ?
It isn't fair to ask me to comment on things that you read somewhere else, especially without posting a link to those things.
However, the only things that are put into Java's string pool are compile-time string constants and strings for which the intern() method has been called. So that's irrelevant to reading data from files. Unless (a definite possibility) what you read was talking about something completely different. As I said, I have no way of knowing.
It's always possible to write bad code. But using a BufferedReader is the standard way to read lines of text from a file. Did whatever you read somewhere else have a better suggestion?
put every line read into the string pool and would eventually blow out memory. Is that the one you were thinking of? That's not the case; there was a correction further down the thread. You can read forever as long as you're not saving the lines in a collection or something.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com