Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getFileLines(final File file) throws IOException { final InputStream inputStream = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); final List<String> lines = new ArrayList<String>(); boolean done = false; while (!done) { final String line = reader.readLine(); done = (line == null); if (line != null) { lines.add(line); } } reader.close(); inputStream.close(); return lines; } }