Welcome to the World of Online Learning:
Hello Friends “This blog helps you to learn Java programming concepts. You can learn Java language at your own speed and time. One can learn concepts of Java language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Write a Java Program to Read the Content of a File Line by Line
PROGRAM: Java Program to Read the Content of a File Line by Line
/*Java Program to Read the Content of a File Line by Line*/
1: Java Program to Read File Using BufferedInputStream
import java.io.File;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
try {
// create a new file object
File file = new File(“input.txt”);
// create an object of Scanner
// associated with the file
Scanner sc = new Scanner(file);
// read each line from file and print it
System.out.println(“Reading File Using Scanner:”);
while(sc.hasNextLine()) {
System.out.println(sc.nextLine());
}
// close scanner
sc.close();
} catch (Exception e) {
e.getStackTrace();
}
}
}