import java.io.File; public class ExceptionHandlingExample { public static void main(String[] args) { File file = new File("nonexistent.txt"); try { if (!file.createNewFile()) { System.out.println("File already exists."); } } catch (IOException e) { System.out.println("Error occurred: " + e.getMessage()); } } }