Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-28-2008, 09:50 PM
Member
 
Join Date: May 2008
Posts: 6
Tsiliadoros is on a distinguished road
compareTo()
Hi everyone, i want to compare two pathnames with compareTo can someone plz upload a quick example using compareTo() method of class file?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-28-2008, 10:14 PM
Member
 
Join Date: Apr 2007
Location: USA
Posts: 50
derrickD is on a distinguished road
Are you looking for something like this?
Code:
public class StringComparator implements Comparator { /* * (non-Javadoc) * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { String str1 = (String) o1; String str2 = (String) o2; if (str1.compareTo(str2) > 0) { return 1; } if (str1.compareTo(str2) < 0) { return -1; } else return 0; } }
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-28-2008, 10:21 PM
Member
 
Join Date: May 2008
Posts: 6
Tsiliadoros is on a distinguished road
compareTo()
I'm very sorry, what i actually want is .equals()

i want to compare pathnames of mp3 files and output if they are the same or

not and i confused with compareTo

I found what i want sorry for wasting your time
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-28-2008, 11:22 PM
Member
 
Join Date: May 2008
Posts: 21
gogoc is on a distinguished road
in that case it will be better if u use .equalsIgnoreCase() because file path with different casing are considered same in windows..
__________________
get new coding problems at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-28-2008, 11:36 PM
Member
 
Join Date: May 2008
Posts: 6
Tsiliadoros is on a distinguished road
.equalsIgnoreCase()
Thanks man this is useful for what i want to do.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-03-2008, 03:18 PM
Member
 
Join Date: Oct 2008
Posts: 24
kellaw is on a distinguished road
mark thread as solved since its already solved
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 12:09 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org