本文整理汇总了Java中java.net.Inet6Address.getByName方法的典型用法代码示例。如果您正苦于以下问题:Java Inet6Address.getByName方法的具体用法?Java Inet6Address.getByName怎么用?Java Inet6Address.getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.Inet6Address
的用法示例。
在下文中一共展示了Inet6Address.getByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTableInputFormatBaseReverseDNSForIPv6
import java.net.Inet6Address; //导入方法依赖的package包/类
@Test
public void testTableInputFormatBaseReverseDNSForIPv6()
throws UnknownHostException, NamingException {
String address = "ipv6.google.com";
String localhost = null;
InetAddress addr = null;
TableInputFormat inputFormat = new TableInputFormat();
try {
localhost = InetAddress.getByName(address).getCanonicalHostName();
addr = Inet6Address.getByName(address);
} catch (UnknownHostException e) {
// google.com is down, we can probably forgive this test.
return;
}
System.out.println("Should retrun the hostname for this host " +
localhost + " addr : " + addr);
String actualHostName = inputFormat.reverseDNS(addr);
assertEquals("Should retrun the hostname for this host. Expected : " +
localhost + " Actual : " + actualHostName, localhost, actualHostName);
}
示例2: assumeIPv6Available
import java.net.Inet6Address; //导入方法依赖的package包/类
protected void assumeIPv6Available() {
try {
InetAddress address = Inet6Address.getByName("0:0:0:0:0:0:0:1");
Assume.assumeTrue(address.isReachable(1000));
} catch (IOException exception) {
Assume.assumeTrue(false);
}
}