This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "compareTo() function doubt" Watch "compareTo() function doubt" New topic

compareTo() function doubt

Anupama Sudhakaran

Joined: Feb 22, 2010
Posts: 18
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

Joined: Oct 27, 2005
Posts: 19541

If you would have read the Javadoc of 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!

How To Ask Questions How To Answer Questions
Anupama Sudhakaran

Joined: Feb 22, 2010
Posts: 18
Thank you
I agree. Here's the link:
subject: compareTo() function doubt
Similar Threads
can anyone explain me about compareTo()
Comparing two huge files
accessing .newsrc files...
Numberformat exception
how to find the difference between Dates