Here you can find the source of readURL(URL url)
private static String readURL(URL url) throws IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; public class Main { private static String readURL(URL url) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream is = url.openStream(); int r;/* w w w.j a v a 2 s . c om*/ while ((r = is.read()) != -1) { baos.write(r); } return new String(baos.toByteArray()); } }