code: private static int parseIntKey(CharSequence key) {
          int numSpaces = 0;
          StringBuilder digits = new StringBuilder();
  
          // build a string from the numerical characters
          for (int i=0; i<key.length(); i++) {
              char c = key.charAt(i);
              if (' ' == c) {
                  numSpaces++;
              } else if (Character.isDigit(c)) {
                  digits.append(c);
              }
          }
  
          String s = digits.toString();
          // This may be greater than the max value for signed integers
          long n = Long.parseLong(s);
  
          // result is the numerical value divided by the number of spaces
          return (int) (n / numSpaces);
      }
docs: /*
  Parse a string as an integer according to the algorithm defined in the WebSocket protocol
  (draft Hixie-76)
  
  @param key Sec-WeSocket-Key[1|2] key value
  @return