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 ) { // More efficient buf . append ( singleChar ) ; } else { buf . append ( separator ) ; } } } return buf . toString ( ) ; } else { return "" ; } }
Joins the given iterable objects using the given separator into a single string .