Here you can find the source of getIPs()
public final static String getIPs()
//package com.java2s; //License from project: Open Source License import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; public class Main { public final static String getIPs() { StringBuilder v_Ret = new StringBuilder(); Enumeration<?> v_NetInterfaces = null; InetAddress v_IP = null;//from w ww . ja va 2s.com try { v_NetInterfaces = NetworkInterface.getNetworkInterfaces(); } catch (java.net.SocketException e) { return v_Ret.toString(); } while (v_NetInterfaces.hasMoreElements()) { NetworkInterface v_NetInterface = (NetworkInterface) v_NetInterfaces.nextElement(); Enumeration<?> v_Addresses = v_NetInterface.getInetAddresses(); int v_Count = 0; v_Ret.append(v_NetInterface.getName()).append("="); while (v_Addresses.hasMoreElements()) { v_IP = (InetAddress) v_Addresses.nextElement(); if (v_IP != null && v_IP instanceof Inet4Address) { v_Ret.append(v_IP.getHostAddress()); v_Count++; if (v_Count > 1) { v_Ret.append(";"); } } } v_Ret.append(" "); } return v_Ret.toString().trim(); } }