Here you can find the source of getRequest(String urlString)
public static String getRequest(String urlString)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String getRequest(String urlString) { StringBuilder result = new StringBuilder(); URL url = null;/* w w w.j av a 2s . com*/ BufferedReader rd = null; HttpURLConnection conn = null; try { url = new URL(urlString); } catch (MalformedURLException e) { e.printStackTrace(); } try { if (url != null) { conn = (HttpURLConnection) url.openConnection(); } if (conn != null) { conn.setRequestMethod("GET"); rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); } String line; assert rd != null; while ((line = rd.readLine()) != null) { result.append(line); } rd.close(); } catch (IOException e) { e.printStackTrace(); } return result.toString(); } }