Here you can find the source of getIPAddress()
private static String getIPAddress()
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; public class Main { private static String getIPAddress() { String ipAddress = ""; try {//from ww w .ja va 2 s .c o m URL whatismyip = new URL("http://icanhazip.com"); BufferedReader in = new BufferedReader(new InputStreamReader(whatismyip.openStream())); ipAddress = in.readLine(); System.out.println(ipAddress); } catch (Exception e) { // TODO log4j } return ipAddress; } }