Java Utililty Methods CSV String Create

List of utility methods to do CSV String Create

Description

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

Method

Stringcsv(String separator, String... elements)
csv
if (elements.length == 0)
    return null;
StringBuilder sb = new StringBuilder(elements[0]);
for (int i = 1; i < elements.length; i++) {
    sb.append(separator).append(elements[i]);
return sb.toString();
StringgetCSV(Collection coll)
get CSV
StringBuffer sb = new StringBuffer();
Iterator iterator = coll.iterator();
while (iterator.hasNext()) {
    sb.append(iterator.next().toString());
    if (iterator.hasNext())
        sb.append(",");
return sb.toString();
...
StringgetCSV(Collection values)
get CSV string from the collections.
return getCSV(values, CSV_SEPARATOR, true);
StringgetCsv(Collection collection)
get Csv
String result = "";
if (collection.size() != 0) {
    result = getLocalCsv(collection);
return result;
StringgetCSVPhrase(Collection objects)
Creates CSV phrase from objects
return getCSVPhrase(objects, COMMA_CHAR);
StringtoCSV(int[] a)
to CSV
String ret = "";
for (int i = 0; i < a.length; i++) {
    if (i != 0) {
        ret += ',' + a[i];
    } else {
        ret += a[i];
return ret;
StringtoCsv(Object[] arr, String format)
to Csv
String ans = "";
if (arr.length > 0) {
    ans += String.format(format, arr[0]);
String format2 = "," + format;
for (int i = 1; i < arr.length; i++) {
    ans += String.format(format2, arr[i]);
ans += "\n";
return ans;
StringtoCsv(String value)
Formats a string for CSV escaping it as a double quoted CSV string if necessary
if (value.contains(",")) {
    return "\"" + escapeQuotesForCsv(value) + "\"";
} else {
    return value;
StringtoCSV3_2(double[][][] array, int index1, int index3)
to CS_
int len2 = array[index1].length;
if (len2 == 0) {
    return "";
StringBuffer s = new StringBuffer();
s.append(Double.toString(array[index1][0][index3]));
for (int i = 1; i < len2; i++) {
    s.append(";").append(Double.toString(array[index1][i][index3]));
...
StringtoCSVBuffer(byte barr[])
to CSV Buffer
StringBuffer sb = new StringBuffer(barr.length + 1);
sb.append('#');
for (int idx = 0; idx < barr.length; idx++) {
    sb.append(Integer.toHexString((int) barr[idx]));
return sb.toString();