+private StringBuilder token;
 +private String source;
 +private int at;
 +
 +//helper functions
 +private int remaining() {
 +  return source.length() - at;
 +}
 +
 +private char peek() throws IOException {
 +  if (at < source.length()) {
 +    return source.charAt(at);
 +  } else {
 +    throw new IOException("ERROR: private char peek()");
 +  }
 +}
 +
 +private char read() throws IOException {
 +  final char c = peek();
 +  at += 1;
 +  return c;
 +}
 +
 +public String next() throws IOException {
 +  // Skip all leading whitespace
 +  while (remaining() > 0 && Character.isWhitespace(peek()) {
 +    read();  // ignore the result because we already know that it is a whitespace character
 +  }
 +  if (remaining() <= 0) {
 +    return null;
 +  } else if (peek() == ‘”’) {
 +    readWithQuotes();
 +  } else {
 +    readWithNoQuotes();
 +  }
 +}
 +
 +private String readWithNoQuotes() throws IOException {
 +  token.setLength(0);  // clear the token
 +  while (remaining() > 0 && !Character.isWhitespace(peek())) {
 +    token.append(read());
 +  }
 +  return token.toString();
 +}
 +
 +private String readWithQuotes() throws IOException {
 +  token.setLength(0);  // clear the token
 +  if (read() != ‘”’) {
 +    throw new IOException(“Strings must start with opening quote”);
 +  }
 +  while (peek() != ‘”’) {
 +    token.append(read());
 +  }
 +  read(); // read the closing the quote that allowed us to exit the loop
 +  return token.toString();
 +}
 +
 +//main class
 +public final class Tokenizer {
 +  public Tokenizer(String source) { ... }
 +  public String next() throws IOException { ... }
 +}

@@ -1,21 +1,20 @@
-+
 private StringBuilde
@@ -23,17 +23,16 @@
 token;%0A 
-+
 private 
@@ -47,17 +47,16 @@
 ource;%0A 
-+
 private 
@@ -64,20 +64,18 @@
 nt at;%0A 
-+
 %0A 
-+
 //helper
@@ -86,17 +86,16 @@
 ctions%0A 
-+
 private 
@@ -113,17 +113,16 @@
 ng() %7B%0A 
-+
   return
@@ -145,24 +145,21 @@
  - at;%0A 
-+
 %7D%0A 
-+
 %0A 
-+
 private 
@@ -192,17 +192,16 @@
 tion %7B%0A 
-+
   if (at
@@ -219,25 +219,24 @@
 ength()) %7B%0A 
-+
     return s
@@ -250,25 +250,24 @@
 harAt(at);%0A 
-+
   %7D else %7B%0A 
@@ -262,25 +262,24 @@
   %7D else %7B%0A 
-+
     throw ne
@@ -320,38 +320,34 @@
  peek()%22);%0A 
-+
   %7D%0A 
-+
 %7D%0A 
-+
 %0A 
-+
 private char
@@ -376,17 +376,16 @@
 tion %7B%0A 
-+
   final 
@@ -402,17 +402,16 @@
 eek();%0A 
-+
   at += 
@@ -414,17 +414,16 @@
  += 1;%0A 
-+
   return
@@ -427,24 +427,21 @@
 urn c;%0A 
-+
 %7D%0A 
-+
 %0A 
-+
 public S
@@ -475,17 +475,16 @@
 tion %7B%0A 
-+
   // Ski
@@ -509,17 +509,16 @@
 espace%0A 
-+
   while 
@@ -567,25 +567,24 @@
 (peek()) %7B%0A 
-+
     read(); 
@@ -664,23 +664,21 @@
 racter%0A 
-+
   %7D%0A 
-+
   if (re
@@ -692,25 +692,24 @@
 () %3C= 0) %7B%0A 
-+
     return n
@@ -714,17 +714,16 @@
  null;%0A 
-+
   %7D else
@@ -741,25 +741,24 @@
  == %E2%80%98%E2%80%9D%E2%80%99) %7B%0A 
-+
     readWith
@@ -768,17 +768,16 @@
 tes();%0A 
-+
   %7D else
@@ -776,25 +776,24 @@
   %7D else %7B%0A 
-+
     readWith
@@ -809,22 +809,18 @@
 );%0A 
-+
   %7D%0A 
-+
 %7D%0A 
-+
 %0A 
-+
 priv
@@ -863,33 +863,32 @@
  IOException %7B%0A 
-+
   token.setLengt
@@ -914,17 +914,16 @@
  token%0A 
-+
   while 
@@ -974,25 +974,24 @@
 peek())) %7B%0A 
-+
     token.ap
@@ -1001,31 +1001,29 @@
 d(read());%0A 
-+
   %7D%0A 
-+
   return tok
@@ -1038,24 +1038,21 @@
 ing();%0A 
-+
 %7D%0A 
-+
 %0A 
-+
 private 
@@ -1097,17 +1097,16 @@
 tion %7B%0A 
-+
   token.
@@ -1140,17 +1140,16 @@
  token%0A 
-+
   if (re
@@ -1160,25 +1160,24 @@
  != %E2%80%98%E2%80%9D%E2%80%99) %7B%0A 
-+
     throw ne
@@ -1233,23 +1233,21 @@
 ote%E2%80%9D);%0A 
-+
   %7D%0A 
-+
   while 
@@ -1265,17 +1265,16 @@
 %E2%80%98%E2%80%9D%E2%80%99) %7B%0A 
-+
     toke
@@ -1296,15 +1296,13 @@
 );%0A 
-+
   %7D%0A 
-+
   re
@@ -1371,17 +1371,16 @@
 e loop%0A 
-+
   return
@@ -1403,16 +1403,13 @@
 );%0A 
-+
 %7D%0A 
-+
 %0A 
-+
 //ma
@@ -1418,17 +1418,16 @@
  class%0A 
-+
 public f
@@ -1450,17 +1450,16 @@
 izer %7B%0A 
-+
   public
@@ -1493,17 +1493,16 @@
  ... %7D%0A 
-+
   public
@@ -1544,11 +1544,10 @@
  ... %7D%0A 
-+
 %7D%0A

Update Tokenizer.java