如何转换数组类型 InetAddress
InetAddress[] inetAddress
进入字符串数组,如下所示!
String[] addrSplit = ??
如何转换数组类型 InetAddress
InetAddress[] inetAddress
进入字符串数组,如下所示!
String[] addrSplit = ??
惯于
String[] addrSplit = new String[inetAddress.length];
for (int i = 0; i < addrSplit.length; i++) {
addrSplit[i] = inetAddress[i].toString();
}
工作?
遍历InetAddress
数组并在需要InetAddress#getCanonicalHostName()
时返回FQDN地址,或者 返回此 IP 地址的主机名。String
InetAddress#getHostName()
只需循环 inetaddress
InetAddress[] inetAddress;
String[] data= new String[inetAddress.length];
for (int i = 0; i < inetAddress.length; i++) {
data[i]=inetAddress[i].getHostAddress();
}
这个怎么样:
String[] addrSplit = new String[inetAddress.length];
for (int i = 0; i < addrSplit.length; i++) {
addrSplit[i] = inetAddress[i].toString();
}