As far I know, the two most common methods of reading character-based data from a file in Java is using Scanner
or BufferedReader
. I also know that
In currently latest JDK6 release/build (b27), the Scanner has a smaller buffer (1024 chars) as opposed to the BufferedReader (8192 chars), but it's more than sufficient.
As to the choice, use the Scanner
if you want to parse the file, use the BufferedReader
if you want to read the file line by line. Also see the introductory text of their aforelinked API documentations.
nextXxx()
methods in Scanner
class.