Reputation: 4740
Is there a reason why createNewFile() method from java.io.File throws an IOException, but mkdir() from the same class does not?
Upvotes: 2
Views: 575
Reputation: 403591
Because the java.io
classes are very poorly designed. There's very little consistency in the API.
It's annoying and unfortunate, but you have to read the javadocs carefully when using those methods, to see exactly how they behave on a case-by-case basis.
You can look forward to JDK7, which has a brand new file handling API.
Upvotes: 5