Here you can find the source of getResponseBody(HttpURLConnection conn)
public static String getResponseBody(HttpURLConnection conn)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; public class Main { public static String getResponseBody(HttpURLConnection conn) { BufferedReader br = null; StringBuilder body = null; String line = ""; try {// w w w .j a v a 2s . c o m br = new BufferedReader(new InputStreamReader( conn.getInputStream())); body = new StringBuilder(); while ((line = br.readLine()) != null) body.append(line); return body.toString(); } catch (Exception e) { throw new RuntimeException(e); } } public static String getResponseBody(InputStream is) { BufferedReader br = null; StringBuilder body = null; String line = ""; try { // we use xPath to get the baseUrl and accountId from the XML // response body br = new BufferedReader(new InputStreamReader(is)); body = new StringBuilder(); while ((line = br.readLine()) != null) body.append(line); return body.toString(); } catch (Exception e) { throw new RuntimeException(e); // simple exception handling, please // review it } } }