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");
}
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)