Java URL Read getHtml(String url)

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

Description

get Html

License

Open Source License

Declaration

static String getHtml(String url) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    static String getHtml(String url) throws Exception {
        StringBuilder result = new StringBuilder();
        HttpURLConnection conn = (HttpURLConnection) new URL(url)
                .openConnection();/* w  ww .j a  va2 s  . co  m*/
        conn.setRequestMethod("GET");
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                conn.getInputStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            result.append(line);
        }
        reader.close();
        return result.toString();
    }
}

Related

  1. getFileSize(String sURL)
  2. getFileSize(URL url)
  3. getFilesizeFromUrl(String urlString)
  4. getFromURL(String URL)
  5. getHTML(String pageURL, String encoding)
  6. getHtml(String urlString)
  7. getHTML(String urlToRead)
  8. getHTML(String urlToRead)
  9. getHttpResponse(HttpURLConnection conn, int expectedReturnCode)