join Iterable<String> to string - Android java.lang

Android examples for java.lang:String Join

Description

join Iterable<String> to string

Demo Code

import android.content.Context;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String joinStrings(String joiner, Iterable<String> parts) {
        StringBuilder builder = new StringBuilder();
        boolean first = true;
        for (String part : parts) {
            if (!first) {
                builder.append(joiner);/* w  w  w. j av  a  2s. c  om*/
            }
            builder.append(part);
            first = false;
        }
        return builder.toString();
    }

}

Related Tutorials