/** Fetches a website from the given URL. * * @param targetURL * @return the website as a string * @throws IOException */ public static String executeGet(String targetURL) throws IOException { URL url; HttpURLConnection connection = null; // Create connection url = new URL(targetURL); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); // configure socket settings connection.setUseCaches(false); connection.setDoInput(true); connection.setReadTimeout(15000); // wait 15 seconds //System.out.println("connection prepared. now sending"); // Send & Get Response InputStream is = connection.getInputStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer response = new StringBuffer(); while ((line = rd.readLine()) != null) { response.append(line); response.append('\r'); } connection.disconnect(); rd.close(); return response.toString(); }