Here you can find the source of queryHtml(String url)
public static String queryHtml(String 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.HttpURLConnection; import java.net.URL; public class Main { public static String queryHtml(String url) throws IOException { HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); connection.setInstanceFollowRedirects(true); int code = connection.getResponseCode(); if (code == 200) { InputStream in = connection.getInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) != -1) { out.write(buffer, 0, len); }/* w w w. j av a2 s . c om*/ return out.toString(); } System.out.println("url:" + url + " code:" + code); throw new IOException("error"); } }