Here you can find the source of toCsv(final List
Parameter | Description |
---|---|
list | List to be converted. Optimistic code, the strings on the list should <b>not</b> contain <b>;</b> |
public static String toCsv(final List<String> list)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**/* www. ja v a2 s .c o m*/ * Convert List of strins to csv * @param list List to be converted. Optimistic code, the strings on the list * should <b>not</b> contain <b>;</b> * @return String separated by ; */ public static String toCsv(final List<String> list) { return toString(list, ';'); } /** * Convert a list of strings to a string separated by delimiter * @param list List * @param delimiter Delimiter * @return String */ public static String toString(final List<String> list, char delimiter) { final StringBuilder b = new StringBuilder(); if (list != null) { for (int i = 0; i < list.size(); i++) { b.append(list.get(i)); if (i != list.size() - 1) { b.append(delimiter); } } } return b.toString(); } }