Java 测试URL地址是否能正常连接
发布时间:2016-08-19 16:00:05
1 public static int testWsdlConnection(String address) throws Exception { 2 int status = 404; 3 try { 4 URL urlObj = new URL(a ...
1 public static int testWsdlConnection(String address) throws Exception { 2 int status = 404; 3 try { 4 URL urlObj = new URL(address); 5 HttpURLConnection oc = (HttpURLConnection) urlObj.openConnection(); 6 oc.setUseCaches(false); 7 oc.setConnectTimeout(3000); // 设置超时时间 8 status = oc.getResponseCode();// 请求状态 9 if (200 == status) {10 // 200是请求地址顺利连通。。11 return status;12 }13 } catch (Exception e) {14 e.printStackTrace();15 throw e;16 }17 return status;18 }
原标题:Java 测试URL地址是否能正常连接
关键词:JAVA
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。
华东5日旅游:https://www.vstour.cn/t/华东5日旅游.html
华东5日游:https://www.vstour.cn/t/华东5日游.html
华东5日游线路:https://www.vstour.cn/t/华东5日游线路.html
华东5省旅游:https://www.vstour.cn/t/华东5省旅游.html
华东5市旅游:https://www.vstour.cn/t/华东5市旅游.html
华东5市旅游价格:https://www.vstour.cn/t/华东5市旅游价格.html
珠海长隆横琴剧院有多少座位:https://www.vstour.cn/a/334172.html
珠海长隆横琴剧院在哪里?附禁带物品:https://www.vstour.cn/a/334173.html