Here you can find the source of getLocalIPList()
public static List<String> getLocalIPList()
//package com.java2s; //License from project: Open Source License import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; public class Main { public static List<String> getLocalIPList() { List<String> ipList = new ArrayList<>(); try {/*w ww . j a v a 2s. com*/ Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); NetworkInterface networkInterface; Enumeration<InetAddress> inetAddresses; InetAddress inetAddress; String ip; while (networkInterfaces.hasMoreElements()) { networkInterface = networkInterfaces.nextElement(); inetAddresses = networkInterface.getInetAddresses(); while (inetAddresses.hasMoreElements()) { inetAddress = inetAddresses.nextElement(); if (inetAddress instanceof Inet4Address && !"127.0.0.1".equals(inetAddress.getHostAddress())) { // IPV4 ip = inetAddress.getHostAddress(); ipList.add(ip); } } } } catch (Exception e) { System.out.println("get local host error >> " + e.getMessage()); } return ipList; } }