Here you can find the source of doGetRequest(String urlStr)
public static String doGetRequest(String urlStr)
//package com.java2s; /**/*from w ww .j a va 2 s . c om*/ * Utilities about the http protocol, currently featuring get requests * * License: LGPLv3 * * @author Janmm14 * @since 2.0.0 */ 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 doGetRequest(String urlStr) { try { URL url = new URL(urlStr); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return response.toString(); } catch (IOException ex) { ex.printStackTrace(); return null; } } }