Here you can find the source of loadFileOrUrlToList(String iFileOrUrl)
Reads text from EITHER a remote URL (that starts with http://) OR a local file (doesn't start with http://), into a list of strings, each containing one line of the file.
public static List<String> loadFileOrUrlToList(String iFileOrUrl) throws IOException
//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 { /**/* w w w .j av a2 s. c o m*/ * Reads text from EITHER a remote URL (that starts with http://) OR a local file (doesn't start with http://), into a list of strings, each containing one line of the file. */ public static List<String> loadFileOrUrlToList(String iFileOrUrl) throws IOException { return iFileOrUrl.startsWith("http://") ? loadUrlToList(new URL(iFileOrUrl)) : loadFileToList(new File(iFileOrUrl)); } /** * 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 a local file into a list of strings, each containing one line of the file. */ public static List<String> loadFileToList(File iFile) throws IOException { return loadReaderToList(new FileReader(iFile)); } /** * 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; } }