Here you can find the source of getResposeText(HttpURLConnection connection)
public static String getResposeText(HttpURLConnection connection) throws IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; public class Main { public static String getResposeText(HttpURLConnection connection) throws IOException { InputStream is = connection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len;/*from w w w .java2s . c o m*/ while ((len = is.read(buffer)) > 0) { baos.write(buffer, 0, len); } String responseText = baos.toString("UTF8"); return responseText; } }