Here you can find the source of read(String pathName)
public static List<String> read(String pathName)
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> read(String pathName) { if (pathName != null) { try { return readFree(new File(pathName)); } catch (FileNotFoundException e) { e.printStackTrace();/* w ww.j a v a2 s . com*/ } catch (IOException e) { e.printStackTrace(); } } return null; } public static List<String> read(File file) { if (file != null) { try { return readFree(file); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return null; } private static List<String> readFree(File file) throws IOException { List<String> archive = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new FileReader(file)); String s; do { s = reader.readLine(); if (s != null) { archive.add(s); } } while (s != null); reader.close(); return archive; } }