public static String join ( String start , String linePrefix , Collection < ? > lines ) { if ( lines . isEmpty ( ) ) { return "" ; } StringBuilder out = new StringBuilder ( start ) ; for ( Object line : lines ) { out . append ( linePrefix ) . append ( line ) . append ( "\n" ) ; } return out . substring ( 0 , out . length ( ) - 1 ) ; //lose last EOL }
Joins Strings with EOL character