URL url = null; try { url = new URL(xmlFullName); URLConnection conn = url.openConnection(); conn.setConnectTimeout(1000);//Set Timeout = 1 s conn.setReadTimeout(1000); InputStream in = conn.getInputStream(); in.close(); System.out.println("Network connection successful"); } catch (MalformedURLException e) { logger.error("Error in Test URL",e); e.printStackTrace(); } catch (Exception e){ logger.error("Error in Test URL",e); System.out.println("Network connection failed"); }
Java Test network connection and set TimeOut time length
最新推荐文章于 2022-12-05 10:47:43 发布