Java Array to CSV toCSV(double[] as)

Here you can find the source of toCSV(double[] as)

Description

to CSV

License

Open Source License

Declaration

public static String toCSV(double[] as) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import java.util.List;

public class Main {
    public static String toCSV(double[] as) {
        StringBuilder b = new StringBuilder();

        for (int i = 0; i < as.length - 1; i++) {
            b.append(as[i]);//from   ww w  .j  ava  2s  .  com
            b.append(",");
        }
        b.append(as[as.length - 1]);

        return b.toString();
    }

    public static String toCSV(List<String> as) {
        StringBuilder b = new StringBuilder();

        for (int i = 0; i < as.size() - 1; i++) {
            b.append(as.get(i));
            b.append(",");
        }
        b.append(as.get(as.size() - 1));

        return b.toString();
    }
}

Related

  1. ArrayToCsv(Object[] line)
  2. ArrayToCSV(String[] array)
  3. arrayToCsvString(String[] array, char delimiter)
  4. toCSV(int[][] values)
  5. toCSV(Object[] objs)
  6. toCSVString(String[] strArray)