How do I compare the String
http://192.168.74.1/sp/info.php?prodnum=0000000001
with
http://192.168.74.1
I only need to get the http://192.168.74.1 part of first string.
You don't need to extract anything from the first string. You can use String.startsWith:
if (string1.startsWith(string2)) {
// do something
}
1) you can use beginwith function
String Mainstring= "http: // 192.168.74.1/sp/info.php?prodnum=0000000001";
if (Mainstring.startsWith("http: // 192.168.74.1"))
{
//Write your code here
}
2) you can use contains function
boolean retval = Mainstring.contains(cs1);
retval will be true if it exist otherwise false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With