Java URL Load readURL(final URL fileURL)

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

Description

read URL

License

Open Source License

Declaration

public static String readURL(final 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(final URL fileURL) throws IOException {
        return readAll(new InputStreamReader(fileURL.openStream()));
    }//from   w w  w . java 2s . c o  m

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

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

Related

  1. readTextFile(final URL resource)
  2. readTextFileAtUrl(final URL url)
  3. readTextFromUrl(URL url)
  4. readTextStream(URL url, String encoding)
  5. readTextURL(URL url)
  6. readUrl(final URL url)
  7. readUrl(final URL url)
  8. readURL(final URL url)
  9. readURL(String url)