Reputation: 460
File.isDirectory() "returns true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise"
Hovewer I need to know if the file is a directory BEFORE I create it.
How to?
Upvotes: 0
Views: 128
Reputation: 2941
In java File represents either file or directory. You don't know what it is when it doesn't exist. When you have:
File newFile = new File("C:\\name");
You can create either directory:
newFile.mkdir();
OR file:
newFile.createNewFile();
Upvotes: 1