Here you can find the source of readBytesFromURL(String url)
public static byte[] readBytesFromURL(String url) throws Throwable
//package com.java2s; //License from project: LGPL import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URL; public class Main { public static byte[] readBytesFromURL(String url) throws Throwable { URL u = new URL(url); InputStream in;//from w w w . jav a2 s . co m in = u.openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 1024 * 5); byte[] b = new byte[1024]; int read; while ((read = in.read(b)) > 0) { baos.write(b, 0, read); } return baos.toByteArray(); } }