SystemUtils { public static String getDataFromUrl(String url) { try { HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setConnectTimeout(1000); conn.setReadTimeout(1000); conn.setRequestMethod("GET"); if (conn.getResponseCode() != 200) { throw new RuntimeException("Unable to get data for URL " + url); } byte[] b = new byte[2048]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataInputStream d = new DataInputStream((FilterInputStream) conn.getContent()); int c; while ((c = d.read(b, 0, b.length)) != -1) bos.write(b, 0, c); String return_ = new String(bos.toByteArray(), Charsets.UTF_8); logger.info("Calling URL API: {} returns: {}", url, return_); conn.disconnect(); return return_; } catch (Exception ex) { throw new RuntimeException(ex); } }  static String getDataFromUrl(String url); static void cleanupDir(String dirPath, List<String> childdirs); static void createDirs(String location); static byte[] md5(byte[] buf); static String md5(File file); static String toHex(byte[] digest); static String toBase64(byte[] md5);  }
@Test public void testGetDataFromUrl() { String dummyurl = "https: String response = SystemUtils.getDataFromUrl(dummyurl); Assert.assertNotNull(response); }