Java Utililty Methods Array to CSV

List of utility methods to do Array to CSV

Description

The list of methods to do Array to CSV are organized into topic(s).

Method

StringArrayToCsv(Object[] line)
Array To Csv
StringBuilder csvLine = new StringBuilder();
for (Object obj : line) {
    csvLine.append(obj.toString()).append(",");
csvLine.setCharAt(csvLine.length() - 1, '\n');
return csvLine.toString();
StringArrayToCSV(String[] array)
Array To CSV
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; i++) {
    String string = array[i];
    if (i == 0)
        sb.append(string);
    else
        sb.append("," + string);
return sb.toString();
StringarrayToCsvString(String[] array, char delimiter)
Utility method to convert a String array to CSV/TSV row string.
StringBuilder arrayString = new StringBuilder();
for (String arrayElement : array) {
    arrayString.append(arrayElement);
    arrayString.append(delimiter);
return arrayString.toString();
StringtoCSV(double[] as)
to CSV
StringBuilder b = new StringBuilder();
for (int i = 0; i < as.length - 1; i++) {
    b.append(as[i]);
    b.append(",");
b.append(as[as.length - 1]);
return b.toString();
StringtoCSV(int[][] values)
to CSV
String vs[][] = new String[values.length][];
for (int i = 0; i < values.length; i++) {
    vs[i] = new String[values[i].length];
    for (int j = 0; j < values[i].length; j++) {
        vs[i][j] = "" + values[i][j];
return toCSV(vs);
...
StringtoCSV(Object[] objs)
to CSV
return toCSV(objs, false);
StringtoCSVString(String[] strArray)
to CSV String
if (strArray == null)
    return null;
StringBuilder sb = new StringBuilder();
for (Iterator<String> itr = Arrays.asList(strArray).iterator(); itr.hasNext();) {
    String s = itr.next();
    sb.append(s);
    if (itr.hasNext())
        sb.append(",");
...