public static String join ( final Collection < ? > collection , final String separator ) { StringBuffer buffer = new StringBuffer ( ) ; boolean first = true ; Iterator < ? > iter = collection . iterator ( ) ; while ( iter . hasNext ( ) ) { Object next = iter . next ( ) ; if ( first ) { first = false ; } else { buffer . append ( separator ) ; } buffer . append ( next ) ; } return buffer . toString ( ) ; }
joins a collection of objects together as a String using a separator