It’s also possible that the specific issue you’re having isn’t a FileNotFoundException. By using the “Exception” in a catch block (which is the parent class to all Exceptions) this is effectively a “catch all”, since it will run if there is an `Exception or any of its subclasses thrown.
Try the following change:
... catch (Exception e) { System.out.println(e.getClass()); } ...
This will tell you the specific class of the Exception being caught by this block. I’ll bet you’ll find that the Exception is actually an instance of a subclass (such as IOException, for example).
Related Posts:
- unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
- What is the proper way to handle a NumberFormatException when it is expected?
- EOFException – how to handle?
- java.io.FileNotFoundException: the system cannot find the file specified
- Can I catch multiple Java exceptions in the same catch clause?
- Java says FileNotFoundException but file exists
- Java – Access is denied java.io.FileNotFoundException
- javac is not recognized as an internal or external command, operable program or batch file [closed]
- What is a StackOverflowError?
- How to uninstall Eclipse?
- How do I resolve ClassNotFoundException?
- Editor does not contain a main type in Eclipse [duplicate]
- How to replace � in a string
- How to decrypt a SHA-256 encrypted string?
- What’s the C++ version of Java’s ArrayList
- Bad Operand Types for Binary Operator “>”?
- Error occurred during initialization of boot layer FindException: Module not found
- Iterate through a HashMap [duplicate]
- Java optional parameters
- Why would a “java.net.ConnectException: Connection timed out” exception occur when URL is up?
- ‘mvn’ is not recognized as an internal or external command, operable program or batch file
- How to use multiple classes in java in one file?
- Java: Multiple class declarations in one file
- Why do JVM arguments start with “-D”?
- How to split a string in Java
- Java integer-double division confusion
- Example of O(n!)?
- A message body writer for Java class java.util.ArrayList and MIME media type application/json was not found
- How to efficiently remove duplicates from an array without using Set
- How to master Java?
- Understanding the difference between null and ‘\u000’ in Java
- How do you make a deep copy of an object?
- what does Dead Code mean under Eclipse IDE Problems Section
- java, get set methods
- How to solve DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502
- Javadoc @see or {@link}?
- Remote debugging a Java application
- What’s the difference between next() and nextLine() methods from Scanner class?
- How to identify object types in java
- How to parse JSON boolean value?
- How to create an 2D ArrayList in java?
- Insert Dimensions to complete Expression/ReferenceType
- Unable to locate tools.jar
- Possible lossy conversion from double to float, given float values?
- how to fix EXE4J_JAVA_HOME, No JVM could be found on your system error?
- Error: ‘else’ without ‘if’
- How to create a custom exception type in Java?
- Error: JavaFX runtime components are missing, and are required to run this application with JDK 11
- Extracting .jar file with command line
- UnsatisfiedDependencyException: Error creating bean with name
- Change priorityQueue to max priorityqueue
- Only using @JsonIgnore during serialization, but not deserialization
- Cannot change version of project facet Dynamic Web Module to 3.0?
- InvalidKeyException Illegal key size
- javac error: Class names are only accepted if annotation processing is explicitly requested
- JOptionPane YES NO OPTION
- How to check if a String is numeric in Java
- How to get today’s Date?
- Creating a random string with A-Z and 0-9 in Java
- java.lang.ArithmeticException: / by zero
- How can I convert a .jar to an .exe?
- How to fix “error: bad operand types for binary operator ‘||’ ” in java
- “The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe”
- Counting an Occurrence in an Array (Java)
- When is the finalize() method called in Java?
- Java “user.dir” property – what exactly does it mean?
- it throws me error incompatible types: unexpected return value — return 10; please correct it make note where i am doing wrong code?
- Inverse Logistic Function / Reverse Sigmoid Function
- How can I check if a single character appears in a string?
- Java Error – Illegal Modifier for Parameter – Only final Permitted
- Fatal error compiling: tools.jar not found:
- Java: Increment by 2 the two inputted integer
- Sending mail error, javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
- Cannot issue data manipulation statements with executeQuery()
- Why do some classes require main methods and others do not?
- How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
- JPA or JDBC, how are they different?
- Why is Netbeans suggesting I “Flip operands of the binary operators” in my Java code
- How to return nothing from a function that returns value?
- Java simple code: java.net.SocketException: Unexpected end of file from server
- What is the best Java email address validation method?
- Set Date in a single line
- why android studio show error of “Missing constraints in constraintlayout”?
- Change the size of a JTextField inside a JBorderLayout
- java.lang.ArrayIndexOutOfBoundsException: 0
- What’s wrong with overridable method calls in constructors?
- what is the difference between doGet() and doPost() in term of the flow?
- Java 3D Game Engine?
- How to cast ArrayList<> from List<>
- Why cannot cast Integer to String in java?
- java.util.ConcurrentModificationException with iterator
- How to read file from relative path in Java project? java.io.File cannot find the path specified
- How can I view and edit specific aspects of playerdata from my Minecraft server?
- String index out of bounds exception java
- Javadoc @author tag good practices
- A fatal error has been detected by the Java Runtime Environment: SIGSEGV, libjvm
- java.lang.IllegalStateException: Failed to introspect Class
- ShoppingCart.Java Program Assignment
- White spaces are required between publicId and systemId
- Can’t seem to disable Java Automatic Update