Java URL Load loadFromURL(URL url)

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

Description

load From URL

License

Open Source License

Declaration

public static String loadFromURL(URL url) 

Method Source Code

//package com.java2s;

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

import java.net.URL;

public class Main {
    public static String loadFromURL(URL url) {
        if (url == null) {
            return null;
        }//from  w  w w. j  a  v  a  2 s  .  co  m
        try {
            InputStreamReader reader = new InputStreamReader(
                    url.openStream());
            StringBuilder sb = new StringBuilder();
            char[] buf = new char[4096];
            int read;
            while ((read = reader.read(buf)) > 0) {
                sb.append(buf, 0, read);
            }
            ;

            reader.close();
            return sb.toString();
        } catch (IOException e) {
            return null;
        }
    }
}

Related

  1. loadFileNoArray(URL f)
  2. loadFileOrUrlToList(String iFileOrUrl)
  3. loadFromUrl(String url)
  4. loadFromURL(URL url)
  5. loadFromURL(URL url)
  6. loadFully(URL url)
  7. loadFully(URL url)
  8. loadImplementations(URL url, ClassLoader loader)
  9. loadManifest(URL url)