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

public class WIMI {

    public final static String WIP_SITE = "http://automation.whatismyip.com/n09230945.asp";

    // For demo
    public static void main(String[] args) {
	System.out.println(WIMI.whatIsMyIp());
    }

    public static String whatIsMyIp() {
	String result = null;
	InputStream in = null;
	try {
	    URLConnection conn = new URL(WIP_SITE).openConnection();
	    int length = Integer.valueOf(conn.getHeaderField("Content-Length"));
	    byte[] buf = new byte[length];
	    in = conn.getInputStream();
	    in.read(buf);
	    result =  new String(buf);
	}
	catch(IOException e) {
	    e.printStackTrace();
	}
	finally {
	    if (in != null) try { in.close(); } catch(IOException e) { /* ignore */ }
	}
	return result;
    }

}

