Here you can find the source of readPage(String url)
public static String[] readPage(String url)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; public class Main { public static String[] readPage(String url) { url = url.replaceAll(" ", "%20"); ArrayList<String> lines = new ArrayList<String>(); try {//w ww .j a va 2 s. c om final URLConnection con = createURLConnection(url); final BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String line; while ((line = in.readLine()) != null) { lines.add(line); } in.close(); } catch (Exception e) { System.out.println("Error reading page!"); } return lines.toArray(new String[lines.size()]); } public static URLConnection createURLConnection(String url) { try { final URL address = new URL(url); final URLConnection connection = address.openConnection(); connection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0"); connection.setConnectTimeout(5000); connection.setRequestProperty("Content-Type", "image/png"); return connection; } catch (IOException ex) { System.out.println("Error creating connection!"); ex.printStackTrace(); } return null; } }