Here you can find the source of download(String url)
public static byte[] download(String url) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; import java.net.URL; public class Main { public static byte[] download(String url) throws IOException { final ByteArrayOutputStream result = new ByteArrayOutputStream(); try (InputStream is = new URL(url).openStream()) { copy(is, result);//w w w.jav a 2 s. com } return result.toByteArray(); } public static void copy(InputStream is, OutputStream os) throws IOException { final int bufferSize = 8192; final byte[] buffer = new byte[bufferSize]; int readed; while ((readed = is.read(buffer, 0, bufferSize)) != -1) { os.write(buffer, 0, readed); } } }