code: public static String trimAllWhitespace(String str) {
          if (!hasLength(str)) {
              return str;
          }
          StringBuilder buf = new StringBuilder(str);
          int index = 0;
          while (buf.length() > index) {
              if (Character.isWhitespace(buf.charAt(index))) {
                  buf.deleteCharAt(index);
              } else {
                  index++;
              }
          }
          return buf.toString();
      }
docs: Trim <i>all</i> whitespace from the given {@code String}:
  leading, trailing, and in between characters.
  
  @param str the {@code String} to check
  @return the trimmed {@code String}
  @see java.lang.Character#isWhitespace