This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 19654
    
  18

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compareTo() function doubt
 
Similar Threads
Numberformat exception
Comparing two huge files
can anyone explain me about compareTo()
how to find the difference between Dates
accessing .newsrc files...