Here you can find the source of readUrl(String url_str)
public static String readUrl(String url_str)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class Main { public static String readUrl(String url_str) { String text = ""; try {/*w w w. ja v a 2 s. c o m*/ URL url = new URL(url_str); URLConnection hc = url.openConnection(); hc.setConnectTimeout(10000); hc.setConnectTimeout(10000); hc.setReadTimeout(10000); hc.setAllowUserInteraction(false); hc.setDoOutput(true); BufferedReader in = new BufferedReader(new InputStreamReader(hc.getInputStream(), "utf-8")); StringBuilder sb = new StringBuilder(); String line; while ((line = in.readLine()) != null) { sb.append(line + "\n"); } text = sb.toString(); System.err.print("Get page " + url_str + "\n"); } catch (Exception e) { e.printStackTrace(); } return text; } }