public static String join ( Collection < ? > objectsToJoin , String separator ) { if ( ( objectsToJoin != null ) && ! objectsToJoin . isEmpty ( ) ) { StringBuilder builder = new StringBuilder ( ) ; for ( Object object : objectsToJoin ) { builder . append ( object ) ; builder . append ( separator ) ; } // Remove the last separator return builder . substring ( 0 , builder . length ( ) - separator . length ( ) ) ; } else { return EMPTY ; } }
Joins all the strings in the list in a single one separated by the separator sequence .