Here you can find the source of joinStrings(String[] strings, String separator)
Parameter | Description |
---|---|
strings | a parameter |
separator | a parameter |
public static String joinStrings(String[] strings, String separator)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.util.List; public class Main { /**/*from www . j av a2 s . com*/ * Join an array of strings into a single string using a separator * * @param strings * @param separator * @return a single string or null */ public static String joinStrings(String[] strings, String separator) { if (strings == null) { return null; } String res = "";//$NON-NLS-1$ for (int i = 0; i < strings.length; i++) { res += (i > 0) ? separator : "";//$NON-NLS-1$ res += strings[i]; } return res; } public static String joinStrings(List<String> strings, String separator) { if (strings == null) { return null; } StringBuffer res = new StringBuffer(); for (String str : strings) { res.append((res.length() > 0) ? separator : "");//$NON-NLS-1$ res.append(str); } return res.toString(); } }