您现在的位置是:主页 > news > 网站换程序 搜索引擎/站长工具箱
网站换程序 搜索引擎/站长工具箱
admin2025/5/29 3:53:03【news】
简介网站换程序 搜索引擎,站长工具箱,彩页设计软件,深圳做网站的网挺久之前看一篇博客写的, 找不到原博主了,自己封装了一哈。/*** Description: 检查服务器地址是否可以ping通* Param: [ip] 服务器IP地址* return: boolean* Author: YangHang* Date: 2019/1/21 17:41*/private boolean checkIfIPThrough(String ip) {Ru…
网站换程序 搜索引擎,站长工具箱,彩页设计软件,深圳做网站的网挺久之前看一篇博客写的, 找不到原博主了,自己封装了一哈。/*** Description: 检查服务器地址是否可以ping通* Param: [ip] 服务器IP地址* return: boolean* Author: YangHang* Date: 2019/1/21 17:41*/private boolean checkIfIPThrough(String ip) {Ru…
挺久之前看一篇博客写的, 找不到原博主了,自己封装了一哈。
/*** @Description: 检查服务器地址是否可以ping通* @Param: [ip] 服务器IP地址* @return: boolean* @Author: YangHang* @Date: 2019/1/21 17:41*/private boolean checkIfIPThrough(String ip) {Runtime runtime = Runtime.getRuntime(); // 获取当前程序的运行进对象Process process; //声明处理类对象String line; //返回行信息InputStream is; //输入流InputStreamReader isr;// 字节流BufferedReader br;boolean res = false;// 结果try {process = runtime.exec("ping " + ip); // PINGis = process.getInputStream(); // 实例化输入流isr = new InputStreamReader(is);// 把输入流转换成字节流br = new BufferedReader(isr);// 从字节中读取文本while ((line = br.readLine()) != null) {if (line.contains("TTL")) {res = true;break;}}is.close();isr.close();br.close();} catch (IOException e) {System.out.println(e);runtime.exit(1);}return res;}