Exemplo n.º 1
0
 /**
  * The reverse of split - given a collection, takes each element and places it in a string, joined
  * by a delimiter.
  */
 public static String join(Collection c, String delim) {
   StringList sl = new StringList();
   for (Object o : c) {
     String s = o.toString();
     sl.add(s);
   }
   return sl.join(delim);
 }
Exemplo n.º 2
0
 // {{{ main()
 public static void main(String args[]) {
   String teststr = "a,b,c,d,e,f";
   StringList.split(teststr, ",");
   // String joinstr = sl.join(",");
   // assert(teststr.equals(joinstr));
   System.out.println("Test Passed");
 } // }}}
Exemplo n.º 3
0
 /**
  * @param arr array of objects
  * @param delim delimiter to separate strings
  * @return a single string with each element in arr converted to a string and concatenated,
  *     separated by delim.
  */
 public static String join(Object[] arr, String delim) {
   StringList sl = new StringList();
   sl.addAll(arr);
   return sl.join(delim);
 }