Here you can find the source of getHostAddress()
public static String getHostAddress()
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; public class Main { public static String getHostAddress() { String strIP = ""; try {/* w w w. jav a 2s. co m*/ InetAddress thisIp = InetAddress.getLocalHost(); strIP = thisIp.getHostAddress(); } catch (Exception e) { e.printStackTrace(); strIP = ""; } return strIP; } }