/*****************************************************************/ /* Copyright 2013 Code Strategies */ /* This code may be freely used and distributed in any project. */ /* However, please do not remove this credit if you publish this */ /* code in paper or electronic form, such as on a web site. */ /*****************************************************************/ package test; import java.io.File; import java.io.IOException; import java.util.List; import org.apache.commons.io.FileUtils; public class ReadListOfLinesFromFile { public static void main(String[] args) { try { File file = new File("test.txt"); List lines = FileUtils.readLines(file); for (String line : lines) { System.out.println("line:" + line); } } catch (IOException e) { e.printStackTrace(); } } }