Here you can find the source of getText(URL url)
public static String getText(URL url) throws IOException
//package com.java2s; //License from project: LGPL import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String getText(URL url) throws IOException { final StringBuffer buffer = new StringBuffer(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //avoid Resteasy bug connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;" + "q=0.9,image/webp,*/*;q=0.8"); //read response final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = reader.readLine(); while (line != null) { buffer.append(line);/*from www . ja va 2 s . co m*/ line = reader.readLine(); } reader.close(); return buffer.toString(); } }