public static String capitalize(String str) {
    if (str == null || str.length() == 0) return str;

    StringBuilder builder = new StringBuilder();
    builder.append(Character.toUpperCase(str.charAt(0)));
    builder.append(str.substring(1));
    return builder.toString();
  }
Returns the number of whitespace characters at the end of the given line.

@param line
@return
spock-core/src/main/java/org/spockframework/util/TextUtil.java