ReadFile

mail@pastecode.io avatar
unknown
java
2 years ago
467 B
10
Indexable
Never
import java.io.*;
import java.util.Scanner;

public class ReadFile {

    public static void main(String[] args) {

        try{

            Scanner scan_file = new Scanner(new File("sample-cars.txt"));

            while (scan_file.hasNext()){
                System.out.println(scan_file.nextLine());
            }

        } catch (Exception e){
            System.out.println("[!] Error occured while reading file");
            System.exit(1);
        }
    }
}