public String trimTrailing ( String str ) { if ( str == null ) { return null ; } int length = str . length ( ) ; for ( int i = length - 1 ; i >= 0 ; i -- ) { if ( str . charAt ( i ) > ' ' ) { return str . substring ( 0 , i + 1 ) ; } } return "" ; }
Trims all trailing whitespace characters from the given string .