public static String trimTrailing ( String str ) { if ( str == null ) { return null ; } int len = str . length ( ) ; for ( ; len > 0 ; len -- ) { if ( ! Character . isWhitespace ( str . charAt ( len - 1 ) ) ) { break ; } } return str . substring ( 0 , len ) ; }
Trim off trailing blanks but not leading blanks