Here you can find the source of getLocalHostIPAdress()
private static String getLocalHostIPAdress()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; public class Main { /***//from ww w .j av a 2s. c o m * Get Local IP Address */ private static String getLocalHostIPAdress() { String ipAddr = ""; try { InetAddress inetAddr = InetAddress.getLocalHost(); byte[] addr = inetAddr.getAddress(); // Convert to dot representation for (int i = 0; i < addr.length; i++) { if (i > 0) { ipAddr += "."; } ipAddr += addr[i] & 0xFF; } } catch (Exception e) { e.printStackTrace(); } return ipAddr; } }