Here you can find the source of getHtmlContent(String url)
public static String getHtmlContent(String url)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String getHtmlContent(String url) { return getHtmlContent(getConnection(url)); }/*w w w. j a v a2s . c o m*/ public static String getHtmlContent(HttpURLConnection h) { try { return h == null ? null : getInputStreamContent(h .getInputStream()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } public static HttpURLConnection getConnection(String url) { try { return (HttpURLConnection) new URL( url.startsWith("http://") ? url : "http://" + url) .openConnection(); } catch (Exception e) { } return null; } public static String getInputStreamContent(InputStream i) { return getInputStreamContent(i, "UTF-8"); } public static String getInputStreamContent(InputStream i, String encoding) { if (i != null) { BufferedReader pBr; try { pBr = new BufferedReader(new InputStreamReader(i, encoding)); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return null; } StringBuffer pSb = new StringBuffer(); int a = -1; try { while ((a = pBr.read()) != -1) { pSb.append((char) a); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return pSb.toString(); } return null; } }