@Test public void testJoinString(){ List<String> strList = new ArrayList<String>(); strList.add("1"); strList.add("2"); strList.add("3"); assertEquals("1,2,3",StringUtils.joinString(strList, ",")); strList = new ArrayList<String>(); assertEquals("",StringUtils.joinString(strList,",")); strList = new ArrayList<String>(); strList.add("1"); assertEquals("1",StringUtils.joinString(strList,",")); }
public static <T> String joinString(Collection<T> objects, String delim) { StringBuilder sb = new StringBuilder(); Object[] oarray = objects.toArray(); int nobjects = oarray.length; if (nobjects == 0) { return ""; } for (int i = 0; i < nobjects - 1; i++) { sb.append(String.format("%s%s", oarray[i].toString(), delim)); } sb.append(String.format("%s", oarray[nobjects - 1])); return sb.toString(); }
StringUtils { public static <T> String joinString(Collection<T> objects, String delim) { StringBuilder sb = new StringBuilder(); Object[] oarray = objects.toArray(); int nobjects = oarray.length; if (nobjects == 0) { return ""; } for (int i = 0; i < nobjects - 1; i++) { sb.append(String.format("%s%s", oarray[i].toString(), delim)); } sb.append(String.format("%s", oarray[nobjects - 1])); return sb.toString(); } }
StringUtils { public static <T> String joinString(Collection<T> objects, String delim) { StringBuilder sb = new StringBuilder(); Object[] oarray = objects.toArray(); int nobjects = oarray.length; if (nobjects == 0) { return ""; } for (int i = 0; i < nobjects - 1; i++) { sb.append(String.format("%s%s", oarray[i].toString(), delim)); } sb.append(String.format("%s", oarray[nobjects - 1])); return sb.toString(); }  }
StringUtils { public static <T> String joinString(Collection<T> objects, String delim) { StringBuilder sb = new StringBuilder(); Object[] oarray = objects.toArray(); int nobjects = oarray.length; if (nobjects == 0) { return ""; } for (int i = 0; i < nobjects - 1; i++) { sb.append(String.format("%s%s", oarray[i].toString(), delim)); } sb.append(String.format("%s", oarray[nobjects - 1])); return sb.toString(); }  static String displayParsedInt(String strIn); static String escape_html(String html); static String getEST(Throwable th); static String getExtendedStackTrace(Throwable th); static String joinString(Collection<T> objects, String delim); static String asciiString(byte[] asciiBytes); static byte[] asciiBytes(String asciiStr); static boolean strEquals(String a, String b); static String lineWrap(String strIn,int cols); }
StringUtils { public static <T> String joinString(Collection<T> objects, String delim) { StringBuilder sb = new StringBuilder(); Object[] oarray = objects.toArray(); int nobjects = oarray.length; if (nobjects == 0) { return ""; } for (int i = 0; i < nobjects - 1; i++) { sb.append(String.format("%s%s", oarray[i].toString(), delim)); } sb.append(String.format("%s", oarray[nobjects - 1])); return sb.toString(); }  static String displayParsedInt(String strIn); static String escape_html(String html); static String getEST(Throwable th); static String getExtendedStackTrace(Throwable th); static String joinString(Collection<T> objects, String delim); static String asciiString(byte[] asciiBytes); static byte[] asciiBytes(String asciiStr); static boolean strEquals(String a, String b); static String lineWrap(String strIn,int cols);  }