本文整理匯總了Java中java.net.InterfaceAddress.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java InterfaceAddress.equals方法的具體用法?Java InterfaceAddress.equals怎麽用?Java InterfaceAddress.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.InterfaceAddress
的用法示例。
在下文中一共展示了InterfaceAddress.equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.net.InterfaceAddress; //導入方法依賴的package包/類
public static void main(String[] args) {
InterfaceAddress ia1;
InterfaceAddress ia2;
InetAddress loopbackAddr = InetAddress.getLoopbackAddress();
InetAddress broadcast1 = null;
InetAddress broadcast2 = null;
try {
broadcast1 = InetAddress.getByName("255.255.255.0");
broadcast2 = InetAddress.getByName("255.255.0.0");
} catch (UnknownHostException e) {
e.printStackTrace();
}
ia1 = createInterfaceAddress(loopbackAddr, (InetAddress) null, (short)45);
ia2 = createInterfaceAddress(loopbackAddr, (InetAddress) null, (short)45);
compare(ia1, ia2, true);
ia2 = createInterfaceAddress(loopbackAddr, broadcast1, (short)45);
compare(ia1, ia2, false);
ia2 = createInterfaceAddress((InetAddress)null, broadcast1, (short)45);
compare(ia1, ia2, false);
ia1 = createInterfaceAddress(loopbackAddr, broadcast2, (short)45);
ia2 = createInterfaceAddress(loopbackAddr, broadcast2, (short)45);
compare(ia1, ia2, true);
ia1.equals(null);
}
示例2: compare
import java.net.InterfaceAddress; //導入方法依賴的package包/類
static void compare(InterfaceAddress ia1, InterfaceAddress ia2, boolean equal) {
if (ia1.equals(ia2) != equal)
throw new RuntimeException("Failed: " + ia1 + " not equals to " + ia2);
if (ia2.equals(ia1) != equal)
throw new RuntimeException("Failed: " + ia2 + " not equals to " + ia1);
}