Suppose I have a given String like:
String s="\"Name\"=>\"Bruce, Wayne\", \"City\"=>\"Bangalore\", \"Country\"=>\"India\"";
Currently in my program I am splitting that string like this
String[] tokens=s.split(", ");
Now when i try to print tokens[0] the output is going to be
"Name"=>"Bruce
but I want my output to be
"Name"=>"Bruce, Wayne"
I know the reason why is it happening because of the way i am splitting it (", ") What changes should i make in my logic such that i dont have to change my splitter from a comma but again if the data has comma,the csv file should ignore it
Can someone help me with a general solution? The example used was just to make the question clear.
Sample Java Code FYR
class HelloWorld
{
public static void main(String[] args)
{
String s="\"Name\"=>\"Bruce, Wayne\", \"City\"=>\"Gotham\", \"Country\"=>\"USA\"";
String[] tokens=s.split(", ");
System.out.println(tokens[0]);
}
}