public static void main(String[] args) {
boolean status = false;
List<String> list = new ArrayList<String>();
list.add("14.215.177.38");
list.add("47.95.164.112");
list.add("192.168.1.1");
for (int i = 0; i < list.size(); i++) {
try {
status = InetAddress.getByName(list.get(i)).isReachable(10000); //超时应该在10钞以上
if(status) {
LOG.info("设备已连接("+list.get(i)+")");
}else {
LOG.info("该设备已离线("+list.get(i)+")");
}
} catch (UnknownHostException e) {
LOG.error("未知设备("+list.get(i)+")",e);
} catch (IOException e) {
LOG.error("获取设备状态失败("+list.get(i)+")",e);
}
}
}
}
JAVA 获取IP状态
猜你喜欢
转载自blog.csdn.net/qq501569325/article/details/104799634
今日推荐
周排行