How do I catch the null that is thrown if the file object returns null
? I keep getting a java.lang.NullPointerException
.
public static File getFile() {
String filePath = JOptionPane.showInputDialog("Enter the full path to the file you want to open");
File file = new File(filePath);
while(!file.exists()) {
filePath = JOptionPane.showInputDialog("Please enter a valid full path");
}
return file;
}
}