0

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");
}

:icon_question:

Edited by happygeek: fixed formatting

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Minimandz
-1

I found what i did wrong, bt thank u 4 th help

Votes + Comments
Read the forum rules on "chat speak". If you can't write intelligently, don't expect an answer.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.