public static void appendToBuffer ( final StringBuffer buffer , final String string , final String delimiter ) { if ( string == null ) { return ; } // // Only append the delimiter in front if the buffer isn't empty. // if ( buffer . length ( ) == 0 || delimiter == null ) { buffer . append ( string ) ; } else { buffer . append ( delimiter ) . append ( string ) ; } }
Appends a string to a buffer prepending with a delimiter string . For instance this may be used to create a string of comma - delimited values . This does not ignore empty strings .