Hi,
I'm trying to parse a string using coma as the delimeter...
If I pass in "Field1,Field2,Field3,Field4" it works fine..
However, if I pass in "Field1,Field2,,Field4"...
I get...
Param : Field1
Param : Field2
Param : Field4
I can't seem to get it to recognize the empty 3rd field.
Is this just how StringTokenizer works ? maybe I need something more complex ?
Regards.
I'm trying to parse a string using coma as the delimeter...
Code:
public ParseInputString(String inputString)
{
java.util.StringTokenizer st = new java.util.StringTokenizer(inputString, ",");
parseParameter(st);
while (st.hasMoreTokens())
{
String str = new String(st.nextToken());
if (str.length() == 0)
{
System.out.println("Param : Empty Param");
}
else
System.out.println("Param : "+ str);
}
}
If I pass in "Field1,Field2,Field3,Field4" it works fine..
However, if I pass in "Field1,Field2,,Field4"...
I get...
Param : Field1
Param : Field2
Param : Field4
I can't seem to get it to recognize the empty 3rd field.
Is this just how StringTokenizer works ? maybe I need something more complex ?
Regards.