Duke, the Java Mascot, in the waving pose. Duke images are now Free Graphics see duke:Project Home Page for more details. (Photo credit: Wikipedia) |
In this post I am sharing a code on how to read character files line by line for Java version 6 or less. The current java version being 8 and the way to read the files is a bit different, like we use Java NIO primarily. Still for the sake of knowledge this post will help you clear some concepts.
The following source shows you the way to read a file in Java version 6 or less (compatible with JDK 5 but not 4)
It covers most of the error handling cases possible and note that we should close BufferedReader when not in use. The following prints the time taken by the code to read the file and total number of the contents read (In this case I read a file containing all the words of a dictionary)
It covers most of the error handling cases possible and note that we should close BufferedReader when not in use. The following prints the time taken by the code to read the file and total number of the contents read (In this case I read a file containing all the words of a dictionary)
Related articles
0 comments :
Post a Comment