本文整理汇总了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();
}
示例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]);
}
示例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);
}
示例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<>();
}
}
示例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;
}