If you see the signature of createNewFile(), its return type is boolean so that if the file is ceated successfully then the funcion returns true and if a file with the same name exists due to which the file could not be created then it returns false. You can check this out by:
System.out.println("File created = "+file.createNewFile());
I have never faced an IOException while creating a new file so i dont know when the exception is actually thrown... but i presume that it can be raised if the OS interrupts during file creation or if we are attempting to create the file on a remote machine then there can be some failure in the communication channel, socket or access violations.
All the checked exceptions extend from the java.lang.Exception class(there is no class called CheckedException)
For eg:
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
Additionally RuntimeException which is a class extends from java.lang.Exception and all the runtime exceptions like NullPointerException extend from RuntimeException.
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.NullPointerException
If you dont have the java api then you can download the same in html help format(easy to use and search) from the following link:
Javadocs download Regards,
Greg.