What would be the problem with this code?
import java.io.*; import java.util.Scanner; /** * Write a description of class capital here. * * @author (your name) * @version (a version number or a date) */ public class capital (); } } }
where I get this error:
java.lang.IllegalStateException: Scanner closed
at java.util.Scanner.ensureOpen(Scanner.java:1115)
at java.util.Scanner.hasNext(Scanner.java:1379)
at capital.main(capital.java:28)
It doesnt seem to read the file, which was working before.
And would anyone tell me how I can get a message to appear if there is no match from the file? If I use an else statement, the message appears on every line, causing the same message to appear 5 times.
Basically the program is meant to read the file, user inputs part of the name, it shows user the information. If it cannot find it, it needs to show a helpful message.
--- Update ---
I really need help. Its due tomorrow, this is really stressful.