Java URL Read getUrlTxt(String url)

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

Description

get Url Txt

License

LGPL

Declaration

public static String getUrlTxt(String url) throws Exception 

Method Source Code

//package com.java2s;

public class Main {

    public static String getUrlTxt(String url) throws Exception {
        String sLine = "";
        String sText = "";
        java.io.InputStream l_urlStream;
        java.net.URL l_url = new java.net.URL(url);
        java.net.HttpURLConnection l_connection = (java.net.HttpURLConnection) l_url.openConnection();
        l_connection.connect();/* www. j  av  a  2s  .  c  o m*/
        l_urlStream = l_connection.getInputStream();
        java.io.BufferedReader l_reader = new java.io.BufferedReader(new java.io.InputStreamReader(l_urlStream));
        while ((sLine = l_reader.readLine()) != null) {
            sText += sLine;
        }
        return sText;
    }
}

Related

  1. getUrlContentWithRetries(String url, long timeoutMs, long retryDelayMs)
  2. getUrlFollowingRedirects(String possibleRedirectionUrl)
  3. getUrlInfos(String urlAsString, int timeout)
  4. getUrlSource(String url)
  5. getUrlStatus(String url)
  6. readAsString(final URL url)
  7. readListFromURL(URL p_url)
  8. readPage(String url)
  9. readStringFromURL(String sourceURL)