Java URL Load readURL(URL fileURL)

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

Description

read URL

License

Open Source License

Declaration

public static String readURL(URL fileURL) throws IOException 

Method Source Code


//package com.java2s;
// The MIT License

import java.io.BufferedReader;

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

import java.net.URL;

public class Main {
    public static String readURL(URL fileURL) throws IOException {
        return readAll(new InputStreamReader(fileURL.openStream()));
    }//from  w ww. ja  v  a 2s .  c  o m

    public static String readAll(Reader reader) throws IOException {
        StringBuffer buffer = new StringBuffer();

        BufferedReader in = new BufferedReader(reader);
        int ch;
        while ((ch = in.read()) > -1) {
            buffer.append((char) ch);
        }
        in.close();

        return buffer.toString();
    }

    public static String toString(Object[] array) {
        String s = "[Array ";
        if (array != null && array.length > 0) {
            s += array[0];
            for (int i = 1; i < array.length; i++)
                s += "," + array[i];
        }
        s += "]";

        return s;
    }

    public static String toString(boolean b) {
        return b ? "true" : "false";
    }
}

Related

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