Here you can find the source of readHttpBytes(String url)
public static byte[] readHttpBytes(String url) throws IOException
//package com.java2s; //License from project: Creative Commons License import java.io.*; import java.net.URL; public class Main { public static byte[] readHttpBytes(String url) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream httpIn = new URL(url).openStream(); byte[] buffer = new byte[1024]; int n;/*from w ww. j a va 2s. c o m*/ while ((n = httpIn.read(buffer)) != -1) baos.write(buffer, 0, n); httpIn.close(); return baos.toByteArray(); } }