public static String trimTrailingCharacter(String str,char trailingCharacter){
  if (!hasLength(str)) {
    return str;
  }
  StringBuilder sb=new StringBuilder(str);
  while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) {
    sb.deleteCharAt(sb.length() - 1);
  }
  return sb.toString();
}

public static String trimTrailingCharacter ( String str , char trailingCharacter ) { if ( ! hasLength ( str ) ) { return str ; } StringBuilder sb = new StringBuilder ( str ) ; while ( sb . length ( ) > 0 && sb . charAt ( sb . length ( ) - 1 ) == trailingCharacter ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } return sb . toString ( ) ; }
trim all occurrences of the supplied trailing character from the given string .
