Here you can find the source of loadFromURL(URL url)
public static byte[] loadFromURL(URL url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; public class Main { public static byte[] loadFromURL(URL url) throws IOException { InputStream is = null;// w w w .j av a 2s .com try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); is = url.openStream(); int r; byte[] buffer = new byte[8000]; while ((r = is.read(buffer)) >= 0) { if (r == 0) continue; baos.write(buffer, 0, r); } return baos.toByteArray(); } finally { if (is != null) is.close(); } } }