HTTPUtils { public static String getStringFromInputStream(InputStream is) throws IOException { Writer writer = new StringWriter(); char[] buffer = new char[1024]; Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); int n; while ((n = reader.read(buffer)) != -1) { writer.write(buffer, 0, n); } return writer.toString(); }  static InputStream sendPacket(URL url, String requestMethod); static String getStringFromInputStream(InputStream is); static HttpURLConnection openHttpConnection(final URL url, final HTTPConnectionMethods httpConnectionMethod); static HttpURLConnection openHttpConnection(URL url, String requestMethod); static InputStream getHttpConnectionInputStream(HttpURLConnection httpConnection); static Map<String, List<String>> getHttpConnectionHeaderFields(HttpURLConnection httpConnection);  }
@Test public void testGetStringFromInputStream() throws FileNotFoundException, IOException { File openFile = new File(HTTPUtilsTest.testFilePath); InputStream is = null; is = new FileInputStream(openFile); String result = HTTPUtils.getStringFromInputStream(is); if (is != null) is.close(); assertThat(result, is(notNullValue())); assertThat(result.length(), is(not(equalTo(0)))); assertThat(result, containsString("GCS")); }