Java URL Connection getUrlSource(String url)

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

Description

get Url Source

License

Open Source License

Declaration

private static String getUrlSource(String url) throws IOException 

Method Source Code

//package com.java2s;
/*/* w  w w .ja va2s. co  m*/
 * 
 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
 Version 2, December 2004 
    
 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> 
    
 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 
    
 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 
    
 0. You just DO WHAT THE FUCK YOU WANT TO.
 */

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;

import java.net.URL;
import java.net.URLConnection;

public class Main {
    private static String getUrlSource(String url) throws IOException {
        URL yahoo = new URL(url);
        URLConnection yc = yahoo.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "UTF-8"));
        String inputLine;
        StringBuilder a = new StringBuilder();
        while ((inputLine = in.readLine()) != null) {
            a.append(inputLine + "\n");
        }
        in.close();

        return a.toString();
    }
}

Related

  1. getURLContentsAsString(URL url)
  2. getURLDataList(URL StrurlStringing)
  3. getUrlEncoding(URLConnection connection)
  4. getURLForward(URL url)
  5. getURLInputStream(final URL url)
  6. getURLStream(URL url, int level)
  7. getWebPageHtmlContent(String url)
  8. getWebsiteContents(URL url)
  9. httpPost(String urlString, String postPath, Map keyValuePairs)