code: public String nextToken(String separators) {
          separator = 0;
          if (peek != null) {
              String tmp = peek;
              peek = null;
              return tmp;
          }
  
          if (index == string.length()) {
              return null;
          }
  
          StringBuilder sb = new StringBuilder();
  
          boolean hadstring = false; // means no further trimming
          boolean validspace = false; // means include spaces
  
          while (index < string.length()) {
              char c = string.charAt(index++);
  
              if (Character.isWhitespace(c)) {
                  if (index == string.length()) {
                      break;
                  }
  
                  if (validspace) {
                      sb.append(c);
                  }
  
                  continue;
              }
  
              if (separators.indexOf(c) >= 0) {
                  if (returnTokens) {
                      peek = Character.toString(c);
                  } else {
                      separator = c;
                  }
                  break;
              }
  
              switch (c) {
                  case '"':
                  case '\'':
                      hadstring = true;
                      quotedString(sb, c);
                      // skip remaining space
                      validspace = false;
                      break;
  
                  default:
                      sb.append(c);
                      validspace = true;
              }
          }
          String result = sb.toString();
          if (!hadstring) {
              result = result.trim();
          }
  
          if (result.length() == 0 && index == string.length()) {
              return null;
          }
          return result;
      }
docs: Retrieve next token.
  @param separators the separators
  @return the next token.