code: public static String removeTrailing(String string, char c)
    {
      if(string == null) {
        return null;
      }
      final int lastCharIndex = string.length() - 1;
      return string.charAt(lastCharIndex) == c ? string.substring(0, lastCharIndex) : string;
    }
docs: Remove trailing character, if exists.
  
  @param string source string,
  @param c trailing character to eliminate.
  @return source string guaranteed to not end in requested character.