GeeCON Prague 2014*
The moose likes I/O and Streams and the fly likes compareTo() function doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "compareTo() function doubt" Watch "compareTo() function doubt" New topic
Author

compareTo() function doubt

Anupama Sudhakaran
Greenhorn

Joined: Feb 22, 2010
Posts: 18
Hello,
can anyone tell me how does the comparing take place between 2 files using compareTo() belonging to the File API. whether it only compares the path names or the contents of the File?
Thank you in advance
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

If you would have read the Javadoc of java.io.File you would have seen the following:
Compares two abstract pathnames lexicographically. The ordering defined by this method depends upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.

So no, it doesn't check the contents, just the result of getPath().

Whoops, quote tags, not code tags!


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Anupama Sudhakaran
Greenhorn

Joined: Feb 22, 2010
Posts: 18
Thank you
 
GeeCON Prague 2014
 
subject: compareTo() function doubt