import java.io.IOException;
import java.net.ServerSocket;
import java.net.SocketException;

/**
 * Created by Xinan on 11/9/15.
 */
public class WebProxy {
  public static void main(String[] args) {
    try {
      System.out.printf("Server starting...\n");
      int port = Integer.parseInt("1234");
      ServerSocket socket = new ServerSocket(port);
      Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
          try {
            System.out.printf("Server is shutting down...\n");
            socket.close();
          } catch (IOException e) {
            System.out.printf("Error: %s\n", e.getMessage());
          }
        }
      });
      System.out.printf("Listening on %d...\n", port);
      while (!socket.isClosed()) {
        (new RequestHandlerThread(socket.accept())).start();
      }
    } catch (SocketException e) {
      System.out.printf("%s\n", e.getMessage());
    } catch (IOException e) {
      System.out.printf("Error: %s\n", e.getMessage());
    } catch (IndexOutOfBoundsException | NumberFormatException  e) {
      System.out.printf("Invalid argument!\n");
    }
  }
}

@@ -206,57 +206,8 @@
 y %7B%0A
-      System.out.printf(%22Server starting...%5Cn%22);%0A
     
@@ -542,56 +542,27 @@
     
-System.out.printf(%22Error: %25s%5Cn%22, e.getMessag
+e.printStackTrac
 e()
-)
 ;%0A  
@@ -620,9 +620,16 @@
 tf(%22
-L
+Server l
 iste
@@ -643,16 +643,18 @@
  %25d...%5Cn
+%5Cn
 %22, port)
@@ -882,56 +882,27 @@
     
-System.out.printf(%22Error: %25s%5Cn%22, e.getMessag
+e.printStackTrac
 e()
-)
 ;%0A  

Tidy up `WebProxy`