join string array to string - Android java.lang

Android examples for java.lang:String Join

Description

join string array to string

Demo Code

import android.content.Context;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class Main{

    public static String join(String[] strings, String sep) {
        String ret = "";

        for (int i = 0; i < strings.length; i++) {
            ret = ret.concat(strings[i]);

            if (i + 1 < strings.length) {
                ret = ret.concat(sep);//ww  w  .j  a va2s  .  c  o  m
            }
        }

        return ret;
    }

}

Related Tutorials