Java URL Connection getURLDataList(URL StrurlStringing)

Here you can find the source of getURLDataList(URL StrurlStringing)

Description

get URL Data List

License

Open Source License

Declaration

public static List getURLDataList(URL StrurlStringing) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List getURLDataList(URL StrurlStringing) {

        List list = new ArrayList();

        try {//w  ww. j  a  v  a2s  .c om

            System.out.println("Loading - " + StrurlStringing);

            URLConnection connection = StrurlStringing.openConnection();
            connection.connect();

            // Read all the text returned by the server
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String str = in.readLine();

            while (str != null) {
                list.add(str);
                str = in.readLine();
            }

            in.close();
            return list;

        } catch (Exception e) {
            System.out.print("Error : " + e.getMessage());
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getURL(String url)
  2. getUrlAsProperties(String urlString)
  3. getUrlContent(String urlAddress)
  4. getURLContents(URL u, Map data)
  5. getURLContentsAsString(URL url)
  6. getUrlEncoding(URLConnection connection)
  7. getURLForward(URL url)
  8. getURLInputStream(final URL url)
  9. getUrlSource(String url)