1. Introduction
The isDirectory() method tests whether the file provided is a directory.
2. Method signature
Parameters:
- method does not take any parameter
Returns
- true - if the file indicated by this abstract pathname exists and is a directory
Throws
- SecurityException - when we do not have access to the file or directory
3. Examples
3.1. Program that checks if /tmp/frontbackend.txt
and /tmp/frontbackend/
are directories
The output:
4. Conclusion
In this article, we presented File.isDirectory
the method that checks if given File
is a directory in the filesystem. Consider using Files.readAttributes()
method if you need to distinguish an I/O exception from the case that the file is not a directory.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}