@Test public void testJoinStringArray() { assertEquals("", StringUtils.join((String[]) null, "blub")); String[] fooBar = {"foo", "bar"}; assertEquals("foo,bar", StringUtils.join(fooBar, ",")); assertEquals("foo, bar", StringUtils.join(fooBar, ", ")); }
public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } }
StringUtils { public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } } }
StringUtils { public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } }  }
StringUtils { public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } }  static String[] split(String string, char delimiter); static String encodeUrl(String stringToEncode); static String encodeUrlIso(String stringToEncode); static String decodeUrl(String stringToDecode); static String decodeUrlIso(String stringToDecode); static String md5(String stringToEncode); static String sha1(String stringToEncode); static String digest(String string, String digestAlgo, String encoding); static String hex(byte[] bytes); static byte[] parseHex(String hex); static int parseHexDigit(char c); static String resolveEntity(String entity); static String ellipsize(String text, int maxLength); static String ellipsize(String text, int maxLength, String end); static String[] splitLines(String text, boolean skipEmptyLines); static List<String> findLinesContaining(String text, String searchText); static String join(Iterable<?> iterable, String separator); static String join(int[] array, String separator); static String join(String[] array, String separator); }
StringUtils { public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } }  static String[] split(String string, char delimiter); static String encodeUrl(String stringToEncode); static String encodeUrlIso(String stringToEncode); static String decodeUrl(String stringToDecode); static String decodeUrlIso(String stringToDecode); static String md5(String stringToEncode); static String sha1(String stringToEncode); static String digest(String string, String digestAlgo, String encoding); static String hex(byte[] bytes); static byte[] parseHex(String hex); static int parseHexDigit(char c); static String resolveEntity(String entity); static String ellipsize(String text, int maxLength); static String ellipsize(String text, int maxLength, String end); static String[] splitLines(String text, boolean skipEmptyLines); static List<String> findLinesContaining(String text, String searchText); static String join(Iterable<?> iterable, String separator); static String join(int[] array, String separator); static String join(String[] array, String separator);  }