1. Introduction
The exists() method tests whether the file or directory with a specified pathname exists in the filesystem.
2. Method signature
Parameters:
- method does not take any parameter
Returns
- true - if file or directory exists in the filesystem
Throws
- SecurityException - when we do not have access to the file or directory
3. Examples
3.1. Check if file /tmp/frontbackend.txt
exists
The output if file exists:
3.1. Checking if directory /tmp/frontbackend
exists
The output when the specified directory exists in the filesystem will be:
4. Conclusion
In this article we presented File.exists()
the method that was created to check if a specified file or directory exists in the filesystem.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}