I hava a List<String> that I need to serialize or make a String representation.
For example I have:
myList.add("Bob");
myList.add("account");
myList.add("userId");
The list can contain variable number of items and I need it to be serialized in this form:
\Bob\-\account\-\userId\
I can do a for loop like:
String ss;
for (String s: myList) {
s = "\\" + s + "\\";
ss = s + "-";
}
However there will be a "-" in the tail of the resulting String ss
Or is there a Google Guava function to do this already?
You can easily use Apaches Commons StringUtils: