I know this can easily be done by writing a function, however, I was wondering if there was a quick and convenient way to load a List in Java from its String representation.
I will give a small example:
List<String> atts = new LinkedList<String>();
atts.add("one"); atts.add("two"); atts.add("three”);
String inString = atts.toString()); //E.g. store string representation to DB
...
//Then we can re-create the list from its string representation?
LinkedLisst<String> atts2 = new LinkedList<String>();
Thnx!
You wouldn’t want to use toString() for this. Instead you want to use java’s serialize methods. Here is an example:
This is a better solution because you don’t have to split or parse anything. You can also use other methods of serilaizing such as json or xml. What I have showed above is built in Java.