Here you can find the source of toCSVString(Object[] pStringArray)
Parameter | Description |
---|---|
pStringArray | the string array |
public static String toCSVString(Object[] pStringArray)
//package com.java2s; public class Main { /**// ww w. jav a 2s .c o m * Converts a string array to a string of comma-separated values. * * @param pStringArray the string array * @return A string of comma-separated values */ public static String toCSVString(Object[] pStringArray) { return toCSVString(pStringArray, ", "); } /** * Converts a string array to a string separated by the given delimiter. * * @param pStringArray the string array * @param pDelimiterString the delimiter string * @return string of delimiter separated values * @throws IllegalArgumentException if {@code pDelimiterString == null} */ public static String toCSVString(Object[] pStringArray, String pDelimiterString) { if (pStringArray == null) { return ""; } if (pDelimiterString == null) { throw new IllegalArgumentException("delimiter == null"); } StringBuilder buffer = new StringBuilder(); for (int i = 0; i < pStringArray.length; i++) { if (i > 0) { buffer.append(pDelimiterString); } buffer.append(pStringArray[i]); } return buffer.toString(); } }