Java URL Load readUrl(String urlString)

Here you can find the source of readUrl(String urlString)

Description

read Url

License

Open Source License

Declaration

public static String readUrl(String urlString) 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.URL;

public class Main {
    public static String readUrl(String urlString) throws Exception {
        URL url = new URL(urlString);
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
            StringBuilder buffer = new StringBuilder();
            int read;
            char[] chars = new char[1024];
            while ((read = reader.read(chars)) != -1)
                buffer.append(chars, 0, read);

            return buffer.toString();
        }//from  ww  w.ja v  a 2s .c  om
    }
}

Related

  1. readURL(String url)
  2. readURL(String url)
  3. readURL(String URL)
  4. readURL(String url, String charsetName)
  5. ReadURL(String URLAddress)
  6. readURL(URL fileURL)
  7. readURL(URL url)
  8. readURL(URL url)
  9. readUrl(URL url)