没有你说的问题:
package Lianxiyong2;import javaioIOException;
import javanetConnectException;
import javanetInetAddress;
import javanetUnknownHostException;
public class Test22 {
public static void main(String[] args) {
String ip = "19216810";
for (int i = 0; i <= 255; i++) {
InetAddress n;
try {
n = InetAddressgetByName(ip + i);
if (nisReachable(1)) {
Systemoutprintln(ip+i);
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
eprintStackTrace();
} catch (ConnectException e) {
// TODO Auto-generated catch block
Systemoutprintln("==============");
Systemoutprintln(ip + i);
Systemoutprintln("==============");
eprintStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
eprintStackTrace();
}
}
}
}
/
==============
192168100
==============
javanetConnectException: Permission denied
at javanetInet6AddressImplisReachable0(Native Method)
at javanetInet6AddressImplisReachable(Inet6AddressImpljava:77)
at javanetInetAddressisReachable(InetAddressjava:441)
at javanetInetAddressisReachable(InetAddressjava:400)
at Lianxiyong2Test22main(Test22java:15)
19216810100
19216810105
19216810107
19216810109
==============
19216810255
==============
javanetConnectException: Permission denied
at javanetInet6AddressImplisReachable0(Native Method)
at javanetInet6AddressImplisReachable(Inet6AddressImpljava:77)
at javanetInetAddressisReachable(InetAddressjava:441)
at javanetInetAddressisReachable(InetAddressjava:400)
at Lianxiyong2Test22main(Test22java:15)
/
以上就是关于使用Java 测试网络连通性的几种方法全部的内容,包括:使用Java 测试网络连通性的几种方法、java 怎么取到shell脚本里面ping的结果、java 代码ping ip 1-255都能ping通等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)