Reading In Text Files
I'm having a real tough time reading in a text file. I'm using JCreater.
Scanner sc = new Scanner(new File("test.txt"));
I've tried putting test a bunch of places, but I always get
unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
Any Ideas of whats going on? I have the test.txt file in my source folder and class folder.
Ah, all I needed was a throws Exception;
Could someone explain to me what this does and why it is required?
Have a look at the source: Lesson: Exceptions (The Java™ Tutorials > Essential Classes)
this will tell you what you need to know. Best of luck!
You have to put your text file under the src folder of your project.
I think it is IOException )