We have a lot of ways to read file in Java. But this one better, I think


Scanner inFile = null;
File file = new File("c:\\myfile.txt");
try {
inFile = new Scanner(file);
while (inFile.hasNextLine()) {
System.out.println(inFile.nextLine());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}