code: public String next() {
          ensureOpen();
          clearCaches();
  
          while (true) {
              String token = getCompleteTokenInBuffer(null);
              if (token != null) {
                  matchValid = true;
                  skipped = false;
                  return token;
              }
              if (needInput)
                  readInput();
              else
                  throwFor();
          }
      }
docs: Finds and returns the next complete token from this scanner.
  A complete token is preceded and followed by input that matches
  the delimiter pattern. This method may block while waiting for input
  to scan, even if a previous invocation of {@link #hasNext} returned
  <code>true</code>.
  
  @return the next token
  @throws NoSuchElementException if no more tokens are available
  @throws IllegalStateException if this scanner is closed
  @see java.util.Iterator