Just the opposite of trimming a string on the left, this example will trim whitespace from the end of the string using guava, apache commons and spring framework utilities.
Google Guava
This snippet will trim trailing whitespace from a string using guava's CharMatcher. CharMatcher.WHITESPACE will determine whether a character is whitespace then calling trimTrailingFrom will omit all characters that match.
Apache Commons
This snippet will trim blanks or spaces on the right side of a string using apache commons. StringUtils.stripEnd will strip any whitespace from the end of the specified string.
Spring Framework
This snippet will left trim leading whitespace from a string using springframework's StringUtils utility by calling trim trailing whitespace method.