Here you can find the source of loadTextFileAsLines(String fileName)
public static List<String> loadTextFileAsLines(String fileName) throws IOException
//package com.java2s; /*/* w w w .jav a 2 s . co m*/ (C) 2007 Stefan Reich (jazz@drjava.de) This source file is part of Project Prophecy. For up-to-date information, see http://www.drjava.de/prophecy This source file is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1. */ import java.io.*; import java.util.*; public class Main { public final static String charsetForTextFiles = "UTF8"; public static List<String> loadTextFileAsLines(String fileName) throws IOException { if (!new File(fileName).exists()) return null; FileInputStream fileInputStream = new FileInputStream(fileName); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, charsetForTextFiles); List<String> lines = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader(inputStreamReader); String line; while ((line = reader.readLine()) != null) lines.add(line); } finally { inputStreamReader.close(); } return lines; } }