Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a List<Long> to comma separated string [duplicate]

Tags:

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.

like image 748
user2375298 Avatar asked Oct 29 '15 08:10

user2375298


People also ask

How do you convert a List to a comma separated string in python?

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].

How do you add a comma separated string to a List in Java?

List<String> items = Arrays. asList(commaSeparated. split(",")); That should work for you.

How can I convert comma separated string into a List string C#?

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.


1 Answers

You can try this:

StringUtils.join(mylist, ','); 

See org.apache.commons.lang3.StringUtils.

like image 82
Rahul Tripathi Avatar answered Sep 23 '22 19:09

Rahul Tripathi