2

Is there a reason why createNewFile() method from java.io.File throws an IOException, but mkdir() from the same class does not?

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.