Here you can find the source of loadURL(URL url)
public static byte[] loadURL(URL url) throws IOException
//package com.java2s; import java.net.*; import java.io.*; public class Main { public static byte[] loadURL(URL url) throws IOException { int bufSize = 1024 * 2; byte[] buf = new byte[bufSize]; ByteArrayOutputStream bout = new ByteArrayOutputStream(); BufferedInputStream in = new BufferedInputStream(url.openStream()); int n;//from www. j a va2 s. c o m while ((n = in.read(buf)) > 0) { bout.write(buf, 0, n); } try { in.close(); } catch (Exception ignored) { } return bout.toByteArray(); } }