lundi 23 février 2015

Java: Scanner cannot read .txt file



after extensive research, I have not been able to find out why the scanner does not pic up "hurricane.txt" I have it saved as a .txt in the project. I am using NetBeans. Any help is appreciated!



// Openning hurricane data file


try{
System.out.println("Openning hurricane data file...");
Scanner fileInput = new Scanner(new File("hurricane.txt"));
}
catch(FileNotFoundException e){


System.err.println("FileNotFoundException: " + e.getMessage());
return;
}
System.out.println( "File opened successfully...");
System.out.println( "Reading file..." );


This is the output I get:



run:
Openning hurricane data file...
FileNotFoundException: hurricane.txt (The system cannot find the file specified)
BUILD SUCCESSFUL (total time: 1 second)



Aucun commentaire:

Enregistrer un commentaire