Here you can find the source of getIPAddress()
public static synchronized String getIPAddress()
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { private static String gLocalIPAddress; public static synchronized String getIPAddress() { if (gLocalIPAddress != null) return (gLocalIPAddress); try {/*from ww w.jav a2 s. c o m*/ InetAddress address = InetAddress.getLocalHost(); return (address.getHostAddress()); } catch (UnknownHostException e) { return (""); } } }