This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 19651

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
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...