Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.List; public class Main { public static String breakArray(String divider, String... array) { return breakList(divider, Arrays.asList(array)); } public static String breakList(String divider, List<String> list) { String result = ""; for (int i = 0; i < list.size(); ++i) { String val = (String) list.get(i); if (!val.isEmpty()) { result = result + val + (i == list.size() - 1 ? "" : divider); } } return result; } }