This is a read-only archive. No new posts or registrations. Privacy Page
Software

FileNotFoundException

1 min read

This thread's last reply is from . Advice, software, and links below may be out of date — treat specific steps and download links with caution.

Looking for the outcome? Ask AI

Hi, I'm working on this GUI program and I needed to call a method from another class which throws an exception. I tried doing this: Scanner s; s=UsingFiles.setFileScanner("board1") throws FileNotFoundException; But it says I need a semicolon after ("board1"). I did that and it said that "throws FileNotFoundException;" is not a valid expression. Please help!!!!
Hi :welcome:

What programming language are you using? Can you post the whole source code?

FileNotFoundException simply means that the program can not find the specified file. In this case I think it's board1.
Well, I can see you are using Java. I don't know Java. But, from researching the problem, the "throws exception" clause is used when declaring a function. Your code is clearly not declaring a function, it is calling a function and therefore "throws FileNotFoundException" is not valid in this context. The compiler expects an end of line after s=UsingFiles.setFileScanner("board1") thus the reason why it insists you put a semi-colon there and complains about anything extra like "throws FileNotFoundException." I derived that from my 5 minute crash course in Java - so I might be wrong.

Ask AI

AI can make mistakes. Check the cited posts. Archived advice can be out-of-date

Don't include personal information. Questions and selected public posts go to OpenAI. About Ask AI