Java CSV String Convert csvstring(Object[] str)

Here you can find the source of csvstring(Object[] str)

Description

Create a CSV string from an array of objects.

License

Open Source License

Parameter

Parameter Description
str a parameter

Declaration

public static String csvstring(Object[] str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w  w w . j  a v  a 2 s  .  c  o m
     * Create a CSV string from an array of objects. This does NOT enclose strings
     * or espace any special characters, it only joins the elements with a comma.
     * @param str
     * @return
     */
    public static String csvstring(Object[] str) {
        if (str.length > 0) {
            StringBuilder csvBuilder = new StringBuilder();
            for (Object n : str) {
                csvBuilder.append(n.toString()).append(",");
            }
            csvBuilder.deleteCharAt(csvBuilder.length() - 1);
            return csvBuilder.toString();
        } else {
            return "";
        }
    }
}

Related

  1. csvDelimiter(String line)
  2. csvEncode(int value)
  3. csvEncodeString(String value)
  4. csvQuote(String value)
  5. csvString(Object[] objects)
  6. csvTitleToTag(String title, int index)
  7. csvToArray(String dirs)
  8. csvToArray(String line)
  9. csvToValuePerLine(String csv)