在我们只传递一个主机名的以下代码块中,您如何传递多个“主机名”?可能吗?
private static void run() {
String host = "www.google.com";
try {
inetAddress = InetAddress.getAllByName(host);
String all = "";
for (int i = 0; i < inetAddress.length; i++) {
all = all + String.valueOf(i) + " : " + inetAddress[i].toString() + "\n";
Log.d("IPADDR", "IP Address : " + all);
prefs.sethostIPaddress(context, all); //Setting HostIP Address in Preference File
}
}
catch (UnknownHostException e) {
e.printStackTrace();
}
}