Scanner user = new Scanner(System.in);
String word;
System.out.println("Location of file: ");
word = user.nextLine();
FileReader fileOpen = new FileReader(word);
BufferedReader fileRead = new BufferedReader(fileOpen);
How can I do an error check if the user enters a wrong file destination?
I get:
java.io.FileNotFoundException:
when a invalid file destination is entered.
I want the program to say something like
System.out.println("Invalid directory");
I get errors for the methods isDirectory() and exists() telling me they don't exist for the type String when I try:
if (word.exists())
{
//do blah blah
}
else
{
//Print error
}