Here you can find the source of loadLines(String file)
Parameter | Description |
---|---|
file | path of the file whose line must be loaded |
public static List<String> loadLines(String file)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Main { /**/* w w w. j a v a 2 s.com*/ * Load the lines from a local text file into a list of strings. * * @param file path of the file whose line must be loaded * @return the list of lines */ public static List<String> loadLines(String file) { ArrayList<String> rows = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; while ((line = reader.readLine()) != null) { rows.add(line); } } catch (IOException e) { System.err.println("Detected and error while reading file: " + file); return null; } return rows; } }