Here you can find the source of readFileToListOfStrings(File file)
public static List<String> readFileToListOfStrings(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.*; public class Main { public static List<String> readFileToListOfStrings(File file) throws IOException { List<String> strings = new LinkedList<>(); BufferedReader reader = null; try {//w w w. ja v a 2s.c o m reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) { line = line.replaceAll("\r", "").replaceAll("\n", "").replaceAll(" ", ""); strings.add(line); } return strings; } finally { if (reader != null) { reader.close(); } } } }