Convert array of string To CSV format - Android java.lang

Android examples for java.lang:array convert

Description

Convert array of string To CSV format

Demo Code

import android.text.SpannableString;
import android.text.style.URLSpan;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Main{

    public static transient String arrayToCSV(String as[]) {
            StringBuilder stringbuilder = new StringBuilder();
            int i = as.length;
            for (int j = 0; j < i; j++) {
                stringbuilder.append(as[j]);
                stringbuilder.append(",");
            }/*from w  w  w.  j  av a 2s  .c  o m*/

            if (stringbuilder.length() > 0) {
                return stringbuilder.substring(0, -1 + stringbuilder.length());
            } else {
                return "";
            }
        }

}

Related Tutorials