code: private static int parseInt(String integer) throws IOException {
          try {
              int value = Integer.parseInt(integer);
              if (value < 0) {
                  throw new IOException("Invalid number in field name: '"
                          + integer + "'");
              }
              return value;
          } catch (NumberFormatException ex) {
              // It's not an integer
              return -1;
          }
      }
docs: Parse a String to an integer. This wrapper is simply to avoid the try
  catch statement repeatedly. Tests for -1 are sufficient, since it is
  illegal in form data. Valid integers below 1 throw exceptions because
  of this illegality.
  
  @param integer The incoming integer to parse
  @return int The parsed integer, or -1 if it is not an integer
  @throws IOException if errors occur during the parse