import
java.net.Inet6Address;
import
java.net.InetAddress;
import
java.net.UnknownHostException;
import
java.util.Arrays;
public
class
inet6add
{
public
static
void
main(String[] args)
throws
UnknownHostException
{
String host =
"localhost"
;
byte
add[] = {
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
};
Inet6Address ip1 = Inet6Address.getByAddress(host, add,
5
);
Inet6Address ip2 = Inet6Address.getByAddress(
null
, add,
6
);
System.out.println(
"Scope Id : "
+ ip1.getScopeId());
System.out.println(
"Scoped Interface : "
+ ip1.getScopedInterface());
System.out.println(
"Address : "
+ Arrays.toString(ip1.getAddress()));
System.out.println(
"Host Address : "
+ ip1.getHostAddress());
System.out.println(
"isAnyLocalAddress : "
+ ip1.isAnyLocalAddress());
System.out.println(
"isLinkLocalAddress : "
+ ip1.isLinkLocalAddress());
System.out.println(
"isLoopbackAddress : "
+ ip1.isLoopbackAddress());
System.out.println(
"isMCGlobal : "
+ ip1.isMCGlobal());
System.out.println(
"isMCLinkLocal : "
+ ip1.isMCLinkLocal());
System.out.println(
"isMCNodeLocal : "
+ ip1.isMCNodeLocal());
System.out.println(
"isMCOrgLocal : "
+ ip1.isMCOrgLocal());
System.out.println(
"isMCSiteLocal : "
+ ip1.isMCSiteLocal());
System.out.println(
"isMulticastAddress : "
+ ip1.isMulticastAddress());
System.out.println(
"isSiteLocalAddress : "
+ ip1.isSiteLocalAddress());
System.out.println(
"hashCode : "
+ ip1.hashCode());
System.out.println(
"ip1==ip2 : "
+ ip1.equals(ip2));
}
}