Here you can find the source of getResponseContent(HttpURLConnection connection)
public static String getResponseContent(HttpURLConnection connection) throws IOException
//package com.java2s; /**/*from ww w.j a v a 2 s . c o m*/ * Copyright (C) 2010 BonitaSoft S.A. * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation * version 2.1 of the License. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License along with this * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301, USA. **/ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; public class Main { public static String getResponseContent(HttpURLConnection connection) throws IOException { InputStream is = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer response = new StringBuffer(); try { while ((line = reader.readLine()) != null) { response.append(line); response.append('\n'); } } finally { reader.close(); is.close(); } return response.toString().trim(); } }