Java URL Load readTextFileAtUrl(final URL url)

Here you can find the source of readTextFileAtUrl(final URL url)

Description

read Text File At Url

License

Apache License

Declaration

public static String readTextFileAtUrl(final URL url) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class Main {
    public static String readTextFileAtUrl(final URL url) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
        StringBuilder sb = new StringBuilder();

        String inputLine;//w  w  w .ja va  2 s. c om
        while ((inputLine = br.readLine()) != null) {
            sb.append(inputLine + "\n");
        }

        br.close();
        return sb.toString();

    }
}

Related

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