brabec
brabec

Reputation: 4740

IOException from java.io.File methods

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

Answers (1)

skaffman
skaffman

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

Related Questions