Join array To String via StringBuilder - Android java.lang

Android examples for java.lang:StringBuilder

Description

Join array To String via StringBuilder

Demo Code

import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main{

    public static String arrayToString(String[] array, String separator) {

        if (array == null || array.length == 0) {
            return "";
        }// w w w .j a  v  a 2  s.co  m
        StringBuilder result = new StringBuilder();
        for (String temp : array) {
            result.append(temp).append(separator);
        }
        return result.substring(0, result.length() - 2);
    }

}

Related Tutorials