FileNotFoundException (original) (raw)
EDIT: Solved
If my project is constraining me to ask the user for a file path and name... but the user may not have one to enter, is there a way to use
System.out.println("Welcome to the Electronic Address Book Application!"
+ "\n\nPlease enter file path and name. If no file, just press enter.");
addressFile = keyboard.readLine();
if(addressFile != null)
{
BufferedReader myInFile = new BufferedReader(new FileReader(addressFile));
addressBook = new AddressBook(myInFile);
myInFile.close();
}
The way it is set up, if the user presses
, I get this as CLI output:
Welcome to the Electronic Address Book Application!
Please enter file path and name. If no file, just press enter.
Exception in thread "main" java.io.FileNotFoundException: (No such file or dire
ctory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.
(FileInputStream.java:106)
at java.io.FileInputStream.(FileInputStream.java:66)
at java.io.FileReader.(FileReader.java:41)
at ElectronicAddressBookApp.main(ElectronicAddressBookApp.java:22)
Press any key to continue . . .