Java InetAddress Check getInetAddressList(NetworkInterface netInterface)

Here you can find the source of getInetAddressList(NetworkInterface netInterface)

Description

get Inet Address List

License

Open Source License

Declaration

public static List<String> getInetAddressList(NetworkInterface netInterface) 

Method Source Code

//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;
    }
}

Related

  1. arrayToList(final InetAddress[] addresses)
  2. canTcpListen(InetAddress address, int port)
  3. checkIPMatch(String ipTemplateList, InetAddress addr)
  4. createRandomSocketAddressList( InetAddress bindAddress, int preferredPort, int minPort, int maxPort)
  5. formatAddresses( List addresses)
  6. is6to4(InetAddress addr)
  7. isAddressReachable(InetAddress address)
  8. isAny(InetAddress ip)
  9. isBroadcastAddress(InetAddress address)