Here you can find the source of readHttpConnection(HttpURLConnection h)
public static byte[] readHttpConnection(HttpURLConnection h) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.util.ArrayList; public class Main { public static byte[] readHttpConnection(HttpURLConnection h) throws IOException { ArrayList<Byte> a = new ArrayList<Byte>(100); InputStream is = h.getInputStream(); int i = is.read(); while (i != -1) { a.add((byte) i); i = is.read();//from ww w . j a va2 s .co m } byte b[] = new byte[a.size()]; i = 0; for (Byte y : a) { b[i++] = y; } return b; } }