Tuesday, 20 August 2013

File.mkdir doesn't throw IOException when File.createNewFile does

File.mkdir doesn't throw IOException when File.createNewFile does

The File class lets you create new directories and new files on a file
system.
The methods to accomplish this are:
public boolean createNewFile() throws IOException
-and-
public boolean mkdir()
How does the operation of creating a new file potentially lead to an
IOException being thrown but the operation of creating a new directory
does not?
I'm trained as a Java developer to be very aware of operations that throw
checked exceptions, so I would be expecting more symmetry here.

No comments:

Post a Comment