Here you can find the source of slurpStream(URLConnection conn)
public static String slurpStream(URLConnection conn) throws Exception
//package com.java2s; /**/*from w w w .java2 s .c o m*/ * Copyright (c) 2004-2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM - Initial API and implementation */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URLConnection; public class Main { private static final String EMPTY = ""; public static String slurpStream(URLConnection conn) throws Exception { String ret = EMPTY; BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); char[] tmp = new char[8192]; int r; while ((r = in.read(tmp, 0, 8192)) != -1) { ret += new String(tmp, 0, r); } in.close(); return ret; } }