Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java FileNotFoundException

try {
    FileInputStream fileHanlde = new FileInputStream(fileName);    // this file doesn't exist
} catch (FileNotFoundException e) {
    System.out.println("Sorry can't find the file");    // always catch the most specific exception first
} catch (IOException e) {
    System.out.println("Unknown IO error");
} finally {
    System.out.println("Clean up duty");
}
Comment

how to handle filenotfoundexception in java

It will throw a FileNotFoundException if the file doesn't 
exist and cannot be created (doc), but it will create it if it can. 
To be sure you probably should first test that the file exists before 
you create the FileOutputStream (and create with createNewFile() if 
it doesn't)
Comment

PREVIOUS NEXT
Code Example
Java :: delay a function call in java 
Java :: len of number in java 
Java :: boolean print condition java 
Java :: jframe visibility 
Java :: findviewbyid java android 
Java :: android java get current time 
Java :: how to control clip volume java 
Java :: priority queue java comparator lambda 
Java :: convert array to list java 
Java :: java docstring javadoc 
Java :: java check two dates same day 
Java :: java split string 
Java :: onclick listener android 
Java :: change number into array in java 
Java :: get text from a jtextfield 
Java :: bootstrap 4 modal get event related target 
Java :: java string to lower case 
Java :: how to read a excel file in java 
Java :: Get the last Friday of a month in Java 
Java :: from string to date 
Java :: convert int to ascii java 
Java :: java % 
Java :: overloading + operator in java 
Java :: java exception message 
Java :: spigot disable join message 
Java :: pretty print json in console 
Java :: how to convert char to uppercase java 
Java :: radio button java swing 
Java :: enum with numbers java 
Java :: isanagram java 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =