Here you can find the source of loadTextFile(String filename)
public static List<String> loadTextFile(String filename) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> loadTextFile(String filename) throws IOException { List<String> ls = new ArrayList<String>(); String line = ""; BufferedReader reader = null; try {/*from w ww.ja v a 2 s .com*/ reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); while ((line = reader.readLine()) != null) { // Traitement du flux de sortie de l'application si besoin est ls.add(line.trim()); } } catch (FileNotFoundException fnfe) { System.err.println("Erreur fichier : " + filename + " indisponible"); System.exit(1); return null; } catch (IOException ioe) { System.err.println("Erreur sur fichier : " + filename); ioe.printStackTrace(); System.exit(1); return null; } finally { if (reader != null) reader.close(); } return ls; } }