question: public static String trimOrPad ( String str , int length , char padChar ) { String result ; if ( str == null ) { result = "" ; } else { result = str ; } if ( result . length ( ) > length ) { return result . substring ( 0 , length ) ; } while ( result . length ( ) < length ) { result += padChar ; } return result ; }
target:  Trims or pads this string, so it has this exact length.