The canExecute() tests whether the specified path is a 'normal' file, so it is not a directory.
2. Method signature
Parameters:
method does not take any parameter
Returns
true - if pathname exists and is a normal file
Throws
SecurityException - when we do not have access to the file
3. Examples
3.1. The example code that checks if given File objects are files using isFile() method
The output:
4. Conclusion
In this article, we presented isFile() method that checks whether a File object represents an actual file in the filesystem. This method will return true only if the file exists and it is not a directory.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}