The JSR 203 API has all the necessary tools; and in this case the Files class .
Despite its name, it handles all Path . For example, you can use:
Files.isDirectory(thePath)
check if the file is a directory. But there are other ways to test the same thing.
source share