Here you can find the source of getFileContentByLine(String filePath)
public static List<String> getFileContentByLine(String filePath)
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getFileContentByLine(String filePath) { File file = new File(filePath); if (!file.exists() || !file.isFile()) { return null; }//w w w .j a va 2 s . c o m List<String> content = new ArrayList<String>(); try { FileInputStream fileInputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); BufferedReader reader = new BufferedReader(inputStreamReader); String lineContent = ""; while ((lineContent = reader.readLine()) != null) { content.add(lineContent); if (lineContent.contains("$")) System.out.println(lineContent); } fileInputStream.close(); inputStreamReader.close(); reader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return content; } }