Here you can find the source of loadURL(URL url)
public static byte[] loadURL(URL url) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URL; public class Main { /**// w w w.j av a 2s. co m * Load URL contents int a byte array */ public static byte[] loadURL(URL url) throws Exception { byte[] buf = new byte[1024]; InputStream is = null; ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { is = url.openStream(); int n; while (-1 != (n = is.read(buf))) { bout.write(buf, 0, n); } return bout.toByteArray(); } finally { try { is.close(); } catch (Exception e) { } } } }