Here you can find the source of fetchURL(String url_string)
private static byte[] fetchURL(String url_string)
//package com.java2s; // set the license text bitstream import java.net.URL; import java.net.URLConnection; public class Main { /**//from ww w . j a v a2 s.c o m * Fetch the contents of a URL */ private static byte[] fetchURL(String url_string) { try { URL url = new URL(url_string); URLConnection connection = url.openConnection(); byte[] bytes = new byte[connection.getContentLength()]; // loop and read the data until it's done int offset = 0; while (true) { int len = connection.getInputStream().read(bytes, offset, bytes.length - offset); if (len == -1) { break; } offset += len; } return bytes; } catch (Exception exc) { return null; } } }