Here you can find the source of readURL(URL url)
public static final byte[] readURL(URL url) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class Main { public static final byte[] readURL(URL url) throws IOException { URLConnection urlconnection = url.openConnection(); InputStream inputstream = urlconnection.getInputStream(); int i = urlconnection.getContentLength(); if (i <= 0) i = inputstream.available(); if (i <= 0) return null; byte abyte0[] = new byte[i]; for (int j = 0; j < i; j += inputstream.read(abyte0, j, i - j)) ;//from w ww . j ava2s.c o m return abyte0; } }