import java.io.*;
import java.util.Scanner;
public FileRead{
public static void main(String args[]){
File F=new File("file_path");
Scanner scan=new Scanner(F);
while(scan.hasNext()){
System.out.println(scan.nextLine());
}
}
}
File Read Using Scanner Class (java.util.Scanner)
file_path : C:\\Abc\\abc.txt
or C:/Abc/abc.txt
file_path : C:\\Abc\\abc.txt
or C:/Abc/abc.txt
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.