code: public static String trimTrailingCharacter(String str, char trailingCharacter) {
          if (!hasLength(str)) {
              return str;
          }
          StringBuilder buf = new StringBuilder(str);
          while (buf.length() > 0 && buf.charAt(buf.length() - 1) == trailingCharacter) {
              buf.deleteCharAt(buf.length() - 1);
          }
          return buf.toString();
      }
docs: Trim all occurrences of the supplied trailing character from the given {@code String}.
  
  @param str the {@code String} to check
  @param trailingCharacter the trailing character to be trimmed
  @return the trimmed {@code String}