Here you can find the source of readFile(String filePath)
Parameter | Description |
---|---|
filePath | a parameter |
public static List readFile(String filePath)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.List; import java.util.ArrayList; public class Main { /**/*from w ww.ja v a 2s . co m*/ * readFile * @param filePath * @return */ public static List readFile(String filePath) { try { File file = new File(filePath); FileInputStream fis = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); // read lines List rowList = new ArrayList(); String line = ""; while ((line = br.readLine()) != null) { rowList.add(line); } // done return rowList; } catch (Exception e) { e.printStackTrace(); return new ArrayList(); } } }