Thursday, March 30, 2017

Java: List to comma separated string

There are multiple ways, I find the following way pretty useful:

1. Download the jar 'common-lang3.jar'
2. Add the jar in your classpath.
3. The following lines of code, coverts your list to comma separated list
       import org.apache.commons.lang3.StringUtils
   StringUtils.join(yourList, ',');

No comments:

Post a Comment