Java HTTP Read readGetEx(String url)

Here you can find the source of readGetEx(String url)

Description

read Get Ex

License

LGPL

Declaration

public static String readGetEx(String url) throws MalformedURLException, IOException 

Method Source Code


//package com.java2s;
/*/*from   w w  w.  j  ava2 s.  c o m*/
 * Copyright 2014-2016 IvaLab Inc. and contributors below
 * 
 * Released under the LGPL v3 or higher
 * See http://www.gnu.org/licenses/lgpl.txt
 *
 * Date: 2014-10-02
 * 
 * Contributors:
 * 
 * Igor Peonte <igor.144@gmail.com>
 *
 */

import java.io.*;
import java.net.*;

public class Main {
    public static String readGetEx(String url) throws MalformedURLException, IOException {
        String res = "";
        BufferedReader reader = null;

        try {
            HttpURLConnection conn;
            conn = (HttpURLConnection) (new URL(url)).openConnection();

            reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

            String line;

            while ((line = reader.readLine()) != null)
                res += line;

        } finally {
            if (reader != null)
                reader.close();
        }

        return res;
    }
}

Related

  1. getJsonString(String url)
  2. getReader(String url)
  3. getResult(String urlStr, String content)
  4. readData(HttpURLConnection conn)
  5. readError(HttpURLConnection conn)
  6. readHTTPConnection(HttpURLConnection conn)
  7. readHttpConnection(HttpURLConnection h)
  8. readHttpFile(String fileUrl, String referer)
  9. readRaw(URL url)