Here you can find the source of doGet(String targetURL)
Parameter | Description |
---|---|
targetURL | a parameter |
urlParameters | a parameter |
public static String doGet(String targetURL)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class Main { /**/*from w ww. j a va2 s .co m*/ * Retrieve file contents * * @param targetURL * @param urlParameters * @return file contents */ public static String doGet(String targetURL) { URLConnection connection = null; try { // Create connection URL url = new URL(targetURL); connection = url.openConnection(); // Get Response BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder(); String line; while ((line = br.readLine()) != null) { response.append(line); response.append('\r'); } br.close(); return response.toString(); } catch (Exception e) { e.printStackTrace(); return null; } } }