Results 1 to 5 of 5
Thread: Reading In Text Files
- 04-03-2009, 02:06 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 2
- Rep Power
- 0
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.
- 04-03-2009, 02:29 AM #2
Member
- Join Date
- Apr 2009
- Posts
- 2
- Rep Power
- 0
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!
- 04-04-2009, 11:59 AM #4
You have to put your text file under the src folder of your project.
Mak
(Living @ Virtual World)
- 04-04-2009, 11:53 PM #5
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Similar Threads
-
working with files (text files)
By itaipee in forum New To JavaReplies: 1Last Post: 02-24-2009, 11:38 AM -
Reading and Writing Text Files
By kandt in forum New To JavaReplies: 1Last Post: 11-12-2008, 03:15 AM -
Behaving text files like binary files
By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM -
Does OS intervene when reading Java text files
By Tina G in forum Advanced JavaReplies: 1Last Post: 04-07-2008, 02:29 PM -
Applet - reading text files packed into JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 02-08-2008, 09:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks