public static String stripTrailing(final String string, final char ch) {
    //// Preconditons
    if (string == null)
      throw new InvalidParameterException("string cannot be null");
    
    int index = string.length();
    if (index == 0)
      return string;
    while (true) {
      if (index == 0)
        break;
      if (string.charAt(--index) != ch)
        break;
    }
    return string.substring(0, index + 1);
  }