/**
* @return {@link StandardProtocolFamily#INET} for IPv4 address or {@link StandardProtocolFamily#INET6} for IPv6 address
* @throws IllegalArgumentException if the address is neither IPv4 or IPv6
* @since 1.6
*/
public static ProtocolFamily getProtocolFamily(InetAddress address) {
if (address.getAddress().length == IP4_BYTES) {
return StandardProtocolFamily.INET;
} else if (address.getAddress().length == IP6_BYTES) {
return StandardProtocolFamily.INET6;
} else {
throw new IllegalArgumentException("Can't determine protocol family for address: " + address);
}
}
InternetProtocolUtils.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:bt
作者:
评论列表
文章目录