Amro elaswar Amro elaswar - 1 year ago 69
Java Question

change a a list inside a string to a java String[]

I have a string containing a list and by that I mean :

String list = "[\"hello\",\"everyone\"]";

How can I transform that so I can read it as a
? My question might not be very clear but please understand English is not my native language thanks everyone.

Answer Source

You can do it using replace and split methods of String class, e.g.:

String s = "[\"hello\",\"everyone\"]";
String[] split = s.replace("[", "").replace("]", "").split(",");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download