Equality of attributes of two files

Rajendra Gutupalli Rajendra.Gutupalli at Sun.COM
Sun Jul 20 02:16:39 PDT 2008

Hi Alan,

I am looking for a method in BasicFileAttributes such as 'equals() or 
compareTo' which compares basic file attributes of two files.

It would be helpful code such as below works:

BasicFileAttributes ba1 = Attributes.readBasicFileAttributes(file1,false);
BasicFileAttributes ba2 = Attributes.readBasicFileAttributes(file2,false);
if (ba1.equals(ba2)){
 S.O.P("Basic File Attributes of two files are same");

As of now BasicFileAttribute implementation does not seem to override 
equals method.
If the implementation has equals or compareTo methods then it is handy 
for users to compare file attributes of two files without comparing each 
attribute (like ba1.isDirectory()==ba2.isDirectory() etc.).


More information about the nio-dev mailing list