Here you can find the source of getAllLocalIP()
public static List<String> getAllLocalIP() throws Exception
//package com.java2s; //License from project: Apache License import java.net.*; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; public class Main { public static List<String> getAllLocalIP() throws Exception { List<String> result = new ArrayList<String>(); Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces(); while (netInterfaces.hasMoreElements()) { NetworkInterface ni = netInterfaces.nextElement(); Enumeration<InetAddress> ias = ni.getInetAddresses(); while (ias.hasMoreElements()) { InetAddress ip = ias.nextElement(); if (!ip.isLoopbackAddress() && (ip instanceof Inet4Address)) { result.add(ip.getHostAddress()); }/*from w w w . ja v a2s . c o m*/ } } return result; } }