当前位置: 首页>>代码示例>>Java>>正文


Java NetworkInterface.isPointToPoint方法代码示例

本文整理汇总了Java中java.net.NetworkInterface.isPointToPoint方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkInterface.isPointToPoint方法的具体用法?Java NetworkInterface.isPointToPoint怎么用?Java NetworkInterface.isPointToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.NetworkInterface的用法示例。


在下文中一共展示了NetworkInterface.isPointToPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatFlags

import java.net.NetworkInterface; //导入方法依赖的package包/类
/** format network interface flags */
private static String formatFlags(NetworkInterface nic) throws SocketException {
    StringBuilder flags = new StringBuilder();
    if (nic.isUp()) {
        flags.append("UP ");
    }
    if (nic.supportsMulticast()) {
        flags.append("MULTICAST ");
    }
    if (nic.isLoopback()) {
        flags.append("LOOPBACK ");
    }
    if (nic.isPointToPoint()) {
        flags.append("POINTOPOINT ");
    }
    if (nic.isVirtual()) {
        flags.append("VIRTUAL ");
    }
    flags.append("mtu:" + nic.getMTU());
    flags.append(" index:" + nic.getIndex());
    return flags.toString();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:IfConfig.java

示例2: getLocalIpAddress

import java.net.NetworkInterface; //导入方法依赖的package包/类
public String[] getLocalIpAddress() {          
    ArrayList<String> addresses = new ArrayList<String>();
    try {
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
        	NetworkInterface intf = en.nextElement();
        	if(!intf.isPointToPoint() && intf.isUp()) {
	            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
	                InetAddress inetAddress = enumIpAddr.nextElement();
	                if (!inetAddress.isLoopbackAddress() && (inetAddress instanceof Inet4Address)) {
	                    addresses.add(inetAddress.getHostAddress());
	                }
	            }
        	}
         }
     } catch (SocketException ex) {
         CrashLog.getInstance().logException(ex);
     }
     return addresses.toArray(new String[0]);
}
 
开发者ID:wolfgangB33r,项目名称:TabShop-KitchenDisplay,代码行数:20,代码来源:DisplayActivity.java

示例3: probe

import java.net.NetworkInterface; //导入方法依赖的package包/类
/**
 * Return a NetworkConfiguration instance.
 */
public static NetworkConfiguration probe() throws IOException {
    Map<NetworkInterface, List<Inet4Address>> ip4Interfaces = new HashMap<>();
    Map<NetworkInterface, List<Inet6Address>> ip6Interfaces = new HashMap<>();

    List<NetworkInterface> nifs = list(getNetworkInterfaces());
    for (NetworkInterface nif : nifs) {
        // ignore interfaces that are down
        if (!nif.isUp() || nif.isPointToPoint()) {
            continue;
        }

        List<Inet4Address> ip4Addresses = new LinkedList<>();
        List<Inet6Address> ip6Addresses = new LinkedList<>();
        ip4Interfaces.put(nif, ip4Addresses);
        ip6Interfaces.put(nif, ip6Addresses);
        for (InetAddress addr : list(nif.getInetAddresses())) {
            if (addr instanceof Inet4Address) {
                ip4Addresses.add((Inet4Address) addr);
            } else if (addr instanceof Inet6Address) {
                ip6Addresses.add((Inet6Address) addr);
            }
        }
    }
    return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:NetworkConfiguration.java

示例4: getInetAddresses

import java.net.NetworkInterface; //导入方法依赖的package包/类
public static final ArrayList<InetAddress> getInetAddresses(InetAddressFilter inetAddressFilter) {
    try {
        final ArrayList<InetAddress> inetAddresses = new ArrayList<>();
        final Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        while (networkInterfaces.hasMoreElements()) {
            final NetworkInterface networkInterface = networkInterfaces.nextElement();
            if (networkInterface == null || networkInterface.isLoopback() || !networkInterface.isUp() || networkInterface.isVirtual() || networkInterface.isPointToPoint()) {
                continue;
            }
            final Enumeration<InetAddress> addresses = networkInterface.getInetAddresses();
            while (addresses.hasMoreElements()) {
                final InetAddress inetAddress = addresses.nextElement();
                if (inetAddress == null) {
                    continue;
                }
                if (inetAddressFilter.filter(inetAddress)) {
                    inetAddresses.add(inetAddress);
                }
            }
        }
        return inetAddresses;
    } catch (Exception ex) {
        System.err.println("NetworkUtil: getInetAddresses error");
        ex.printStackTrace();
        return new ArrayList<>();
    }
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:28,代码来源:NetworkUtil.java

示例5: getLocalInetAddresses

import java.net.NetworkInterface; //导入方法依赖的package包/类
public static List<InetAddress> getLocalInetAddresses() throws IOException {
    List<InetAddress> ret = new ArrayList<>();

    Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
    if (networkInterfaces == null) {
        return ret;
    }

    while (networkInterfaces.hasMoreElements()) {
        NetworkInterface card = networkInterfaces.nextElement();

        if (card.isLoopback() || card.isPointToPoint() || card.isVirtual() || !card.isUp()) {
            continue;
        }

        Enumeration<InetAddress> addresses = card.getInetAddresses();
        while (addresses.hasMoreElements()) {
            InetAddress inetAddress = addresses.nextElement();
            int index = ret.size();

            if (Inet4Address.class.isInstance(inetAddress)) {
                ret.add(index, inetAddress);
            }
        }
    }

    return ret;
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:29,代码来源:NetworkUtil.java


注:本文中的java.net.NetworkInterface.isPointToPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。