Here you can find the source of readListFromURL(URL p_url)
Parameter | Description |
---|---|
p_url | The input url |
public static List<String> readListFromURL(URL p_url)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.LinkedList; import java.util.List; public class Main { /**/*from ww w. j av a2 s. co m*/ * Reads a list of lines from a url * @param p_url The input url * @return The list of string lines */ public static List<String> readListFromURL(URL p_url) { List<String> text = new LinkedList<String>(); try { URLConnection urlc = p_url.openConnection(); InputStreamReader fisr = new InputStreamReader(urlc.getInputStream()); BufferedReader br = new BufferedReader(fisr); String inLine = br.readLine(); while (inLine != null) { text.add(inLine); inLine = br.readLine(); } } catch (IOException e) { return null; } return text; } }