Please figure out the error
hi all,
heres a problem I can't it out can any one help me.
Its not printing the WieldValue5
the String here it should ignore "SXGI", "F"'s, and "E" and it should print ControlID1
WieldType1
WieldValue1
...
ControlID5
WieldType5
WieldValue5
its not printing "WieldValue5"
publicclass Example{
publicstaticvoid main(String[] args)throws Exception{
String strReq ="SXGIDFControlID1FWieldType1FWieldValue1F" +
"ControlID2FWieldType2FWieldValue2F" +
"ControlID3FWieldType3FWieldValue3F" +
"ControlID4FWieldType4FWieldValue4F" +
"ControlID5FWieldType5FWieldValue5E";
int iIndexF = strReq.indexOf("F");
String strTemp = strReq.substring(iIndexF + 1);
int iIndexE = -1;
while(-1 != iIndexF){
iIndexF = strTemp.indexOf("F");
if(-1 == iIndexF){
thrownew Exception("Error in ControlID");
}
String strControlID = strTemp.substring(0, iIndexF);
System.out.println(strControlID);
int iIndexFieldType = strTemp.indexOf("F", iIndexF + 1);
if(-1 == iIndexFieldType){
thrownew Exception("Error in FieldType");
}
String strFieldType = strTemp.substring(iIndexF + 1, iIndexFieldType);
System.out.println(strFieldType);
int iIndexFieldValue = strTemp.indexOf("F", iIndexFieldType + 1);
String strFieldValue;
if(-1 == iIndexFieldValue){
thrownew Exception("Error in FieldValue");
}
strFieldValue = strTemp.substring(iIndexFieldType + 1, iIndexFieldValue);
System.out.println(strFieldValue);
iIndexF = iIndexFieldValue;
if(-1 == iIndexF){
iIndexE = strTemp.indexOf("E", iIndexFieldType + 1);
if(-1 == iIndexE){
thrownew Exception("Error in FieldValue");
}
strFieldValue = strTemp.substring(iIndexFieldType + 1, iIndexE);
System.out.println(strFieldValue);
iIndexFieldType = iIndexE;
}
strTemp = strTemp.substring(iIndexFieldValue + 1);
System.out.println(strTemp);
}
}
}
null
null

