0

如何转换数组类型 InetAddress

InetAddress[] inetAddress

进入字符串数组,如下所示!

String[] addrSplit = ??
4

4 回答 4

1

惯于

String[] addrSplit = new String[inetAddress.length];
for (int i = 0; i < addrSplit.length; i++) {
    addrSplit[i] = inetAddress[i].toString();
}

工作?

于 2013-02-18T12:01:50.550 回答
1

遍历InetAddress数组并在需要InetAddress#getCanonicalHostName()时返回FQDN地址,或者 返回此 IP 地址的主机名。StringInetAddress#getHostName()

于 2013-02-18T12:03:19.007 回答
0

只需循环 inetaddress

   InetAddress[] inetAddress;
      String[] data= new String[inetAddress.length];
      for (int i = 0; i < inetAddress.length; i++) {
         data[i]=inetAddress[i].getHostAddress();
      }
于 2013-02-18T12:02:15.467 回答
0

这个怎么样:

String[] addrSplit = new String[inetAddress.length];
for (int i = 0; i < addrSplit.length; i++) {
  addrSplit[i] = inetAddress[i].toString();
}
于 2013-02-18T12:04:39.940 回答