indexOf("USA")
Hello All,
I am having a very simple java question.
Sample XML:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <!-- Edited with XML Spy v4.2
-->
- <USA>
<to></to>
<from>Jani</from>
<heading>Reminder</heading>
</USA>
I am using a method in the SeeBeyond JCD:
indexOf("USA")method - this method is returning me always as false even though my XML has USA in it.
I don't understand what the problem is?
Christina
That isn't a "java question". I see nothing to do with java there. So you have an XML file. So you have this mystical thing called the "SeeBeyond JCD" whatever that is. There's no java code you're showing at all, that an answer can be directed towards.
I am really sorry for that.
Java code is as below:
if (((getin().getClient().getPayload().toString()).indexOf("USA") > 0))
{
EGate.collabTrace("I am here ...There is USA in the XML....1");
}
else
{
EGate.collabTrace("I am here .......4.....there is no USA in this XML");
}
I am always getting the message: "I am here .......4.....there is no USA in this XML"
> if (((getin().getClient().getPayload().toString()).indexOf("USA") > 0))
So debug it.
String test = getin().getClient().getPayload().toString();
System.out.println("The string is: " + test);
Obviously it doesn't have "USA" in it (beyond the first character anyway), or that "if" statement would have been true.
Note: you should be checking for >= 0, not just > 0. It returns < 0 if the substring isn't found.