public static String splitListByComma ( List < String > hosts ) { boolean firstHost = true ; StringBuilder hostConnection = new StringBuilder ( ) ; for ( String host : hosts ) { if ( ! firstHost ) { hostConnection . append ( "," ) ; } hostConnection . append ( host . trim ( ) ) ; firstHost = false ; } return hostConnection . toString ( ) ; }
Split list by comma .