Java Network Interface Get getUsualNetworkInterfaces()

Here you can find the source of getUsualNetworkInterfaces()

Description

get Usual Network Interfaces

License

Open Source License

Declaration

public static List<NetworkInterface> getUsualNetworkInterfaces() 

Method Source Code

//package com.java2s;
/**//w  w w  .  j  a v a 2  s .  c  om
 * 
 * @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.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class Main {

    public static List<NetworkInterface> getUsualNetworkInterfaces() {
        List<NetworkInterface> resultList = new ArrayList<NetworkInterface>();
        Enumeration<NetworkInterface> allNetInterfaces;
        try {
            allNetInterfaces = NetworkInterface.getNetworkInterfaces();
            while (allNetInterfaces.hasMoreElements()) {
                NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
                if (netInterface.isLoopback() || netInterface.isVirtual() || !netInterface.isUp()) {
                    continue;
                }
                resultList.add(netInterface);
            }
        } catch (SocketException e) {
            System.out
                    .println("Some error occured during execute method getServerUsualInterface, see details:" + e);
        }
        return resultList;
    }
}

Related

  1. getNetworkInterfaces()
  2. getNIOMulticastMethod()
  3. getNonLoopbackLocalAdresses()
  4. getNonLoopbackNetworkInterface()
  5. getPublicInterface()
  6. isActive(String niName)
  7. isNixMashPC()
  8. parseInterfaceList(String s)
  9. pingFromInterface(String name)