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) throws IOException 

Method Source Code

//package com.java2s;
/**// w  w w .  j a v  a  2  s .com
 * LICENSING
 * 
 * This software is copyright by sunkid <sunkid@iminurnetz.com> and is
 * distributed under a dual license:
 * 
 * Non-Commercial Use:
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Commercial Use:
 *    Please contact sunkid@iminurnetz.com
 */

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.URL;

public class Main {
    public static String readURL(URL url) throws IOException {
        final StringBuilder content = new StringBuilder();
        final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null)
            content.append(inputLine);
        in.close();
        return content.toString();
    }
}

Related

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