Here you can find the source of readFile(String fileName)
public static List<String> readFile(String fileName) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static List<String> readFile(String fileName) throws FileNotFoundException { Scanner s = new Scanner(new File(fileName)); List<String> list = new ArrayList<String>(); while (s.hasNext()) { list.add(s.next());//from w w w . j av a 2s.c om } s.close(); return list; } }