Here you can find the source of getInetAddressList(NetworkInterface netInterface)
public static List<String> getInetAddressList(NetworkInterface netInterface)
//package com.java2s; /**/*from w ww .j ava 2s .c o m*/ * * @Title NetworkUtils.java * @Description ?AppStatus??????????????? * Copyright: Copyright (c) 2013, Opzoon and/or its affiliates. All rights reserved. * OPZOON PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * @author NY * @date 2013-11-30 ????11:02:07 * */ 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> getInetAddressList(NetworkInterface netInterface) { List<String> inetAddressList = new ArrayList<String>(); Enumeration<InetAddress> addresses = netInterface.getInetAddresses(); InetAddress ip = null; while (addresses.hasMoreElements()) { ip = (InetAddress) addresses.nextElement(); if (ip != null && ip instanceof Inet4Address) { inetAddressList.add(ip.getHostAddress()); } } return inetAddressList; } }