public static String padRight ( String string , int size , char padding ) { if ( string == null || size <= string . length ( ) ) { return string ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( string ) ; while ( sb . length ( ) < size ) { sb . append ( padding ) ; } return sb . toString ( ) ; }
Formats a string by padding it with the given character to the right until the given length is reached .