Here you can find the source of join(Collection
Parameter | Description |
---|---|
coll | a parameter |
delimiter | a parameter |
public static String join(Collection<String> coll, String delimiter)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { /****//from w w w.ja va 2s .com * Returns the comma seprated string example:-a@b.com,c@d.com,d@e.com * * @param coll * @param delimiter * @return String */ public static String join(Collection<String> coll, String delimiter) { if (coll.isEmpty()) return ""; StringBuilder sb = new StringBuilder(); for (String x : coll) sb.append(x + delimiter); sb.delete(sb.length() - delimiter.length(), sb.length()); return sb.toString(); } /** * Method is useful for checking the given string is empty or not if it is * empty then return true otherwise return false. * * @param tmp * @return boolean */ public static boolean isEmpty(String str) { if (str == null) return true; if (str.trim().length() == 0) { return true; } return false; } }