Help with Exception...

Thread Solved
Reply

Join Date: Aug 2008
Posts: 4
Reputation: Minimandz is an unknown quantity at this point 
Solved Threads: 0
Minimandz Minimandz is offline Offline
Newbie Poster

Help with Exception...

 
0
  #1
Aug 29th, 2008
Please could sum1 help me with this:

I'm trying to read text from a file using the Scanner class and i'm not sure y its not throwing the FileNotFound Exception

try
{
Scanner sc = new Scanner (new File ("Food.txt"));
wordList[num] = sc.next();

while(sc.hasNext())
{
wordList[num] = sc.next();
System.out.println(wordList[num]);
num++;
}
sc.close();

}
catch ( FileNotFoundexception f)
{
System.out.println("Cannot find the file");
}

Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,527
Reputation: javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light 
Solved Threads: 209
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Help with Exception...

 
0
  #2
Aug 29th, 2008
Probably because the file does not exist.
And you could use BufferedReader for reading from file.
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: Minimandz is an unknown quantity at this point 
Solved Threads: 0
Minimandz Minimandz is offline Offline
Newbie Poster

Re: Help with Exception...

 
-1
  #3
Aug 29th, 2008
I found what i did wrong, bt thank u 4 th help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC