List of utility methods to do HTTP Get
String | doGET(HttpURLConnection conn) do GET conn.setRequestMethod("GET"); return call(conn, null); |
String | doGet(String theURL, Map nameValuePairs) do Get String request = validateURL(theURL); if (nameValuePairs != null && nameValuePairs.size() > 0) { if (!request.endsWith("?")) request += "?"; request += encodeParams(nameValuePairs); URL url = new URL(request); URLConnection conn = url.openConnection(); ... |
String | doGet(String url) Do GET request URL localURL = new URL(url); URLConnection connection = openConnection(localURL); HttpURLConnection httpURLConnection = (HttpURLConnection) connection; httpURLConnection.setRequestProperty("Accept-Charset", charset); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); InputStream inputStream = null; InputStreamReader inputStreamReader = null; BufferedReader reader = null; ... |
String | doGet(String url, HashMap do Get String rawJSONString = ""; String getUrl = buildUrl(url, params); HttpURLConnection connection = (HttpURLConnection) new URL(getUrl).openConnection(); connection.setRequestMethod("GET"); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { ... |
String | doGet(String urlStr) do Get URL url = null; HttpURLConnection conn = null; InputStream is = null; ByteArrayOutputStream baos = null; try { url = new URL(urlStr); conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(TIMEOUT_IN_MILLIONS); ... |
String | doGet(String urlString) do Get InputStream is = null; BufferedReader reader = null; try { URL url = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("Content-Type", "application/json"); conn.setConnectTimeout(connectionTimeOut); ... |
String | doGet(URL url, String... args) _more_ HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); for (int i = 0; i < args.length; i += 2) { connection.setRequestProperty(args[i], args[i + 1]); try { BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); StringBuilder sb = new StringBuilder(); ... |
String | doGetRequest(String urlStr) do Get Request 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) { ... |
String | executeGet(String targetURL) execute Get HttpURLConnection connection = null; try { 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); ... |
HttpURLConnection | getHttpURLConnectionByGET(String resourceURL) Get an object of HttpURLConnection. HttpURLConnection conn = null; if (null != resourceURL && !"".equals(resourceURL.trim())) { URL url = new URL(resourceURL); conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(5000); conn.setRequestMethod("GET"); return conn; ... |