Java tutorial
//package com.java2s; 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; while ((chr = dis.read()) != -1) { sb.append((char) chr); } if (sb != null) { responseMessage = sb.toString(); } return responseMessage; } }