Hi I am having a requirement where I need to convert List
of Long
datatype to comma separated String
. Which would be the appropriate way. I have thought about using string builder or converting it to List<String>
and then using StringUtils
join to get a String
.
I am looking for java 7
solution,Not using guava
or java 8
.
How to Convert a Python List into a Comma-Separated String? You can use the . join string method to convert a list into a string. So again, the syntax is [seperator].
List<String> items = Arrays. asList(commaSeparated. split(",")); That should work for you.
To convert a delimited string to a sequence of strings in C#, you can use the String. Split() method. Since the Split() method returns a string array, you can convert it into a List using the ToList() method.
You can try this:
StringUtils.join(mylist, ',');
See org.apache.commons.lang3.StringUtils.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With