宣传页面效果 bbcode 切换publicOnly showinclass 切换是否免费 localhost xiongzhang how2j.cn (groupid:) clear cache
127.0.0.1 xiongzhang 添加项目比较步骤

free:false
步骤 1 : IPUtil   
步骤 2 : 用法   

package util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class IPUtil { public static boolean isReachable(String ip) { try { boolean reachable = false; Process p = Runtime.getRuntime().exec("ping -n 1 " + ip); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { if (line.length() != 0) sb.append(line + "\r\n"); } reachable = sb.toString().contains("TTL"); br.close(); return reachable; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } } }
System.out.println(IPUtil.isReachable("192.168.2.189"));
System.out.println(IPUtil.isReachable("192.168.2.189"));




提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 软件和工具-工具和软件-IPUtil 的提问

尽量提供截图、代码和异常信息,有助于分析和解决问题。

上传截图