import java.net.*;
import java.io.*;
import java.util.*;

public class MailFind {
    public static void main(String args[]) throws Exception {
	System.out.println("Searching for " + args[0]);
	Socket sock=new Socket("new.usps.com",80);
	OutputStream str = sock.getOutputStream();
	InputStream istr=sock.getInputStream();
	String request;
	String data;
	// request data
	data="tracknbr="+args[0]+"\r\n";
	// Set up request
	request="POST /cgi-bin/cttgate/ontrack.cgi HTTP/1.0\r\n";
	request+="Content-Type: application/x-www-form-urlencoded\r\n";
	request+="Content-Length: " + (data.length())+"\r\n\r\n";
	request+=data;
	// Write it out
	str.write(request.getBytes());
	// For this example, just dump results
	int c;
	do {
	    c=istr.read();
	    if (c!=-1) System.out.print((char)c);
	} while (c!=-1);
	sock.close();
    }
}
