1. Introduction
The equals() method tests if the given pathname is equal to that provided in the argument. This method returns true if the argument is not null and is pointing to the same file or directory. Equality depends upon the underlying operating system. Note that on UNIX systems, the alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.
2. Method signature
Parameters:
- obj - object that should be compared with given
File
instance
Returns
- true - if the objects are the same
3. Examples
3.1. The program presents several comparisons on File
objects
The output:
4. Conclusion
In this article we presented File.equals()
method available in Java IO API. The method checks if two File
instance is equal. Note that this method does not compare the content of the file or directory, it is only checked if pathnames are the same.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}