|
|
| java help |
Expert:Maurice
Code a catch block that catches an IOException, prints the message “An I/O exception occurred.” to the console, and then throws the exception to the calling method.
|
| Answers |
Hi friend,
Code a catch block that catches an IOException :
import java.io.*;
public class CreateFile1{ public static void main(String[] args) { try { File f; f=new File("myfile.txt"); if(!f.exists()){ f.createNewFile(); System.out.println("New file \"myfile.txt\" has been created to the current directory"); } } catch (IOException ioe) { System.out.println("An I/O exception occurred."); }
} }
Thanks
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|