Java URL Load readURL(URL url)

Here you can find the source of readURL(URL url)

Description

read URL

License

Open Source License

Declaration

public static String readURL(URL url) 

Method Source Code

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

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

public class Main {
    public static String readURL(URL url) {
        try {//from   w  w  w. ja va2 s  .  c o  m
            InputStreamReader in = new InputStreamReader(url.openStream());
            char[] buffer = new char[1024];
            int l = 0;
            StringBuilder sb = new StringBuilder();
            while ((l = in.read(buffer, 0, buffer.length)) > -1) {
                sb.append(buffer, 0, l);
            }
            in.close();
            return new String(sb);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. ReadURL(String URLAddress)
  2. readUrl(String urlString)
  3. readURL(URL fileURL)
  4. readURL(URL url)
  5. readUrl(URL url)
  6. readURL(URL url)
  7. readURL(URL url)
  8. readURLasString(URL url)
  9. readUrlContent(String address)