Here you can find the source of fileToLines(String filePath)
Parameter | Description |
---|---|
filePath | a String, the path of the file on the machine |
public static List<String> fileToLines(String filePath)
//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 { /**//from w w w . j a v a2 s . c o m * Converts a File to a List of Strings. * * @param filePath * a String, the path of the file on the machine * @return a List of Strings, containing the information of the file at the * designated file-path */ public static List<String> fileToLines(String filePath) { List<String> lines = new ArrayList<String>(); String line = ""; try { BufferedReader in = new BufferedReader(new FileReader(filePath)); while ((line = in.readLine()) != null) { lines.add(line); } in.close(); } catch (IOException e) { e.printStackTrace(); } return lines; } }