Java Array to CSV toCSVString(String[] strArray)

Here you can find the source of toCSVString(String[] strArray)

Description

to CSV String

License

Open Source License

Declaration

public static String toCSVString(String[] strArray) 

Method Source Code


//package com.java2s;

import java.util.Arrays;

import java.util.Iterator;

public class Main {
    public static String toCSVString(String[] strArray) {
        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);/*from   w w w .  j  a va2s  .co m*/
            if (itr.hasNext())
                sb.append(",");
        }

        return sb.toString();
    }
}

Related

  1. ArrayToCSV(String[] array)
  2. arrayToCsvString(String[] array, char delimiter)
  3. toCSV(double[] as)
  4. toCSV(int[][] values)
  5. toCSV(Object[] objs)