Java URL Load ReadURL(String URLAddress)

Here you can find the source of ReadURL(String URLAddress)

Description

Reads data from an URLAddress to the string

License

Open Source License

Parameter

Parameter Description
URLAddress a parameter

Declaration

public static ArrayList<String> ReadURL(String URLAddress) 

Method Source Code

//package com.java2s;
/*Copyright 2008 by Vladimir Polony, Stupy 24, Banska Bystrica, Slovakia
    //from  w w w .j a  v  a  2s.  c  o m
This file is part of OpenRep FREE homeopathic software.
    
OpenRep FREE 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.
    
OpenRep FREE 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 OpenRep FREE.  If not, see <http://www.gnu.org/licenses/>.*/

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.ArrayList;

public class Main {
    /** Reads data from an URLAddress to the string
     *
     * @param URLAddress
     * @return
     */
    public static ArrayList<String> ReadURL(String URLAddress) {
        URL address;
        try {
            address = new URL(URLAddress);
        } catch (MalformedURLException ex) {
            return null;
        }
        ArrayList<String> sb = new ArrayList();
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(address.openStream()));

            String inputLine;

            while ((inputLine = in.readLine()) != null)
                sb.add(inputLine);
            in.close();
        } catch (Exception e) {
            return null;
        }
        return sb;
    }
}

Related

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