code: public static String rtrim(String str, String defaultValue) {
  	if (str == null) return defaultValue;
  	int len = str.length();
  
  	while ((0 < len) && (str.charAt(len - 1) <= ' ')) {
  	    len--;
  	}
  	return (len < str.length()) ? str.substring(0, len) : str;
      }
docs: This function returns a string with whitespace stripped from the end of str
  
  @param str String to clean
  @return cleaned String