Java URL Load loadUrlToList(URL iUrl)

Here you can find the source of loadUrlToList(URL iUrl)

Description

Reads text from a remote URL into a list of strings, each containing one line of the file.

License

Open Source License

Declaration

public static List<String> loadUrlToList(URL iUrl) throws IOException 

Method Source Code


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

import java.io.*;
import java.net.URL;

import java.util.LinkedList;
import java.util.List;

public class Main {
    /**//from ww  w . j ava2s .  co m
     * Reads text from a remote URL into a list of strings, each containing one line of the file.
     */
    public static List<String> loadUrlToList(URL iUrl) throws IOException {
        return loadReaderToList(new InputStreamReader(iUrl.openStream()));
    }

    /**
     * Reads text from an open reader into a list of strings, each containing one line of the file.
     */
    public static List<String> loadReaderToList(Reader reader) throws IOException {
        List<String> outList = new LinkedList<String>();
        String line;
        BufferedReader bufferedReader = new BufferedReader(reader);
        while ((line = bufferedReader.readLine()) != null)
            outList.add(line);
        return outList;
    }
}

Related

  1. loadText(URL url, boolean allowCache)
  2. loadURL(String urlDesc)
  3. loadURL(URL url)
  4. loadURL(URL url)
  5. loadUrlIntoByteArray(String urlString)
  6. loadURLToString(String url, String EOL)
  7. read(String url)
  8. read(URL file)
  9. read(URL url, String charsetName)