READ A FILE
import java.util.Scanner;
import java.io.File;
public class file {
public static void main(String args[]) throws Exception {
try {
File x = new File("a.txt");
Scanner sc = new Scanner(x);
while (sc.hasNext()) {
System.out.println(sc.next());
}
sc.close();
} catch (Exception e) {
System.out.println("Error");
}
}
}
OUTPUT: SSS
No comments:
Post a Comment