public static final String setSize ( final String s , final int length ) { String result = s ; int oldlen = s . length ( ) ; if ( oldlen > length ) { System . err . println ( "greenpeace.util.setSize(String s,int length): length (" + length + ") is smaller than s.length(" + oldlen + ") : " + s ) ; } else { int tofill = length - oldlen ; result = StringUtil . appendSpaces ( s , tofill ) ; } return result ; }
Appends the necessary amount of spaces to the string until it has the givn length . No Exception is thrown if the length of the String is shorter than the given length but nothing will happen and a message will be printed to the System . out .