aspose file tools*
The moose likes Beginning Java and the fly likes String.equals() not giving desired proper result 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 » Beginning Java
Bookmark "String.equals() not giving desired proper result" Watch "String.equals() not giving desired proper result" New topic
Author

String.equals() not giving desired proper result

Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100



I am trying this code to send sms to user from my site it gives me response as result "Message+Sent+Successfully".
I am trying to check this response with matching substring but it always giving a false i.e "Try it again".
I am unable to find a clue why so??
substring subDisplayMsg is fetching proper substring"Successfully" then what is problem..
Please help me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Print out the length of both strings, and then print them out character by character.


Ping & DNS - updated with new look and Ping home screen widget
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36479
    
  16
There is a method in the String class something like endsWith(). Maybe that will provide what you want.
Krishna Kanth
Ranch Hand

Joined: Oct 23, 2006
Posts: 49
    
    1

Nothing wrong with your code. only possibility is your assumption on display msg. may be the response is in lowercase? try equalsIgnoreCase

I just tried below code and it printed "Message has been sent" for me.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36479
    
  16
Welcome to the Ranch krishna kanth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String.equals() not giving desired proper result
 
Similar Threads
setrequestheader() - User-Agent - no good?
telnet client timeout using BufferedInputStream
Login into JSP through JAVA
POST Request Java
Read XML output from a URL