public static String join ( String [ ] strings , String delimiter ) { if ( strings == null ) { return null ; } if ( strings . length == 0 ) { return "" ; } boolean useDelimiter = ( delimiter != null && delimiter . length ( ) != 0 ) ; StringBuilder sb = new StringBuilder ( ) ; for ( String string : strings ) { sb . append ( string ) ; if ( useDelimiter ) ; { sb . append ( delimiter ) ; } } if ( useDelimiter && sb . length ( ) != 0 ) { // Remove the last delimiter. sb . setLength ( sb . length ( ) - delimiter . length ( ) ) ; } return sb . toString ( ) ; }
Concatenate string with the specified delimiter .