Here you can find the source of getExternalIPAddress()
public static String getExternalIPAddress()
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; public class Main { public static String getExternalIPAddress() { BufferedReader in = null; try {/* w w w .j av a 2 s . com*/ URL whatismyip = new URL("http://automation.whatismyip.com/n09230945.asp"); in = new BufferedReader(new InputStreamReader(whatismyip.openStream())); return in.readLine(); //you get the IP as a String } catch (IOException ex) { } finally { try { in.close(); } catch (IOException ex) { } } return null; } }