本文整理汇总了Java中java.net.NetworkInterface.equals方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkInterface.equals方法的具体用法?Java NetworkInterface.equals怎么用?Java NetworkInterface.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.NetworkInterface
的用法示例。
在下文中一共展示了NetworkInterface.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.net.NetworkInterface; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
boolean passed = true;
try {
MulticastSocket ms = new MulticastSocket();
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface
.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface netIf = networkInterfaces.nextElement();
if (isNetworkInterfaceTestable(netIf)) {
printNetIfDetails(netIf);
ms.setNetworkInterface(netIf);
NetworkInterface msNetIf = ms.getNetworkInterface();
if (netIf.equals(msNetIf)) {
System.out.println(" OK");
} else {
System.out.println("FAILED!!!");
printNetIfDetails(msNetIf);
passed = false;
}
System.out.println("------------------");
}
}
} catch (IOException e) {
e.printStackTrace();
passed = false;
}
if (!passed) {
throw new RuntimeException("Test Fail");
}
System.out.println("Test passed ");
}
示例2: assertNetworkInterfaceEqual
import java.net.NetworkInterface; //导入方法依赖的package包/类
static void assertNetworkInterfaceEqual(
NetworkInterface expectedNetworkInterface,
NetworkInterface deserializedNetworkInterface) {
System.err
.println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:");
if (expectedNetworkInterface == null) {
if (deserializedNetworkInterface == null) {
// ok, do nothing.
System.err.println("Network Interface equality "
+ " NetworkInterface, expected:"
+ expectedNetworkInterface + ", got :"
+ deserializedNetworkInterface);
} else {
System.err.println("Error checking "
+ " NetworkInterface, expected:"
+ expectedNetworkInterface + ", got :"
+ deserializedNetworkInterface);
failed = true;
}
} else if (!expectedNetworkInterface
.equals(deserializedNetworkInterface)) {
System.err.println("Error checking "
+ // versionStr +
" NetworkInterface, expected:" + expectedNetworkInterface
+ ", got :" + deserializedNetworkInterface);
failed = true;
} else {
System.err.println("Network Interface equality "
+ " NetworkInterface, expected:" + expectedNetworkInterface
+ ", got :" + deserializedNetworkInterface);
}
}
示例3: main
import java.net.NetworkInterface; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
int checkFailureCount = 0;
try {
Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces();
while (en.hasMoreElements()) {
NetworkInterface ni = en.nextElement();
Enumeration<InetAddress> addrs = ni.getInetAddresses();
System.out.println("############ Checking network interface + "
+ ni + " #############");
while (addrs.hasMoreElements()) {
InetAddress addr = addrs.nextElement();
System.out.println("************ Checking address + "
+ addr + " *************");
NetworkInterface addrNetIf = NetworkInterface
.getByInetAddress(addr);
if (addrNetIf.equals(ni)) {
System.out.println("Retreived net if " + addrNetIf
+ " equal to owning net if " + ni);
} else {
System.out.println("Retreived net if " + addrNetIf
+ "NOT equal to owning net if " + ni
+ "***********");
checkFailureCount++;
}
}
}
} catch (Exception ex) {
}
if (checkFailureCount > 0) {
throw new RuntimeException(
"NetworkInterface lookup by address didn't match owner network interface");
}
}