Here you can find the source of getString(URL url)
public static String getString(URL url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class Main { public static String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"; public static String getString(URL url) throws IOException { URLConnection page = url.openConnection(); page.addRequestProperty("User-Agent", USER_AGENT); InputStream is = page.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String result = ""; String line = ""; while ((line = br.readLine()) != null) { result += line + "\r\n"; }//from w w w. j a v a2s .co m is.close(); return result; } }