Here you can find the source of getResponseMessage(InputStream inputStream, HttpURLConnection connection)
private static String getResponseMessage(InputStream inputStream, HttpURLConnection connection) throws UnsupportedEncodingException, IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; public class Main { private static String getResponseMessage(InputStream inputStream, HttpURLConnection connection) throws UnsupportedEncodingException, IOException { String responseMessage = null; StringBuffer sb = new StringBuffer(); InputStream dis = connection.getInputStream(); int chr;// w w w.ja v a 2 s .c om while ((chr = dis.read()) != -1) { sb.append((char) chr); } if (sb != null) { responseMessage = sb.toString(); } return responseMessage; } }