Reputation: 4717
In my app, I am reading from HTTP page and converting the Stream via the below method into String.
public static String convertStreamToString(java.io.InputStream is)
{
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
However, once I have the String, I am comparing to another String (manually created in eclipse) which has the exact same component, (which is a copy paste from the same HTML file on my server). The comparison is returning me false.
I am using s1.equalsIgnoreCase(s2). Below is an image how my 2 strings are exactly alike.
Upvotes: 1
Views: 695
Reputation: 82553
Most likely, one of your Strings has some whitespace that results in them being unequal upon comparison.
Calling .trim()
on the Strings before you compare them should fix this.
Upvotes: 1