Here you can find the source of getLocalHostIps()
public static String getLocalHostIps()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { private static String localHostIps = ""; public static String getLocalHostIps() { if (localHostIps.equals("")) { StringBuffer sb = new StringBuffer(); InetAddress[] ias;//from www.j a va 2 s.c o m try { ias = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); for (int i = 0; i < ias.length; i++) { String ip = ias[i].getHostAddress(); sb.append(ip); sb.append(","); } localHostIps = sb.toString(); } catch (UnknownHostException e) { localHostIps = ""; } } return localHostIps; } }