Here you can find the source of executeGet(String targetURL)
public static String executeGet(String targetURL)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String executeGet(String targetURL) { HttpURLConnection connection = null; try {//from w w w .ja v a2 s . c o m //Create connection URL url = new URL(targetURL); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Content-Language", "en-US"); connection.setUseCaches(false); connection.setDoOutput(true); //Get Response InputStream is = connection.getInputStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); StringBuilder response = new StringBuilder(); // or StringBuffer if not Java 5+ String line; while ((line = rd.readLine()) != null) { response.append(line); response.append('\r'); } rd.close(); return response.toString(); } catch (Exception e) { return e.getMessage(); } finally { if (connection != null) { connection.disconnect(); } } } }