StringUtils { public static final String join(String[] array, String separator) { StringBuilder sb = new StringBuilder(1024); boolean first = true; for (String item : array) { if (first) { first = false; } else { sb.append(separator); } sb.append(item); } return sb.toString(); }  static final boolean isEmpty(String str); static final boolean isNotEmpty(String str); static final String join(String[] array, String separator); static final String join(Collection<String> list, String separator); static final String normalizeSpace(String str); static final String trimAll(String str);  }
@Test public void testJoinArray() { Assert.assertEquals("", StringUtils .join(new String[0], ",")); Assert.assertEquals("foo", StringUtils .join(new String[]{"foo"}, ",")); Assert.assertEquals("foo,bar,baz", StringUtils .join(new String[]{"foo", "bar", "baz"}, ",")); }
@Test public void testJoinCollection() { Assert.assertEquals("", StringUtils .join(new ArrayList<String>(), ",")); Assert.assertEquals("foo", StringUtils .join(new ArrayList<>(Arrays.asList("foo")), ",")); Assert.assertEquals("foo,bar,baz", StringUtils .join(new ArrayList<>( Arrays.asList("foo", "bar", "baz")), ",")); }