vendredi 30 octobre 2015

Why can't I find my File?

I'm trying to open a CSV file name "logger.csv" which I have saved in the source folder itself.

public static void main(String[] args) {
    String filename = "logger.csv";
    File motor_readings = new File(filename);
    try {
        Scanner inputStream = new Scanner(motor_readings);
        while (inputStream.hasNext()){
            System.out.println(inputStream.next());
        }
        inputStream.close();
    } catch (FileNotFoundException e) {
        System.out.println("Error: File not found!");
    }
}

However, this keeps on giving me a "File not found" error.

Aucun commentaire:

Enregistrer un commentaire