Android Text File Read fileToListByLine(String fileName)

Here you can find the source of fileToListByLine(String fileName)

Description

file To List By Line

Declaration

public static List<String> fileToListByLine(String fileName)
        throws Exception 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;

import java.io.FileReader;

import java.util.LinkedList;
import java.util.List;

public class Main {

    public static List<String> fileToListByLine(String fileName)
            throws Exception {
        List<String> lineList = new LinkedList<String>();
        String line = "";
        BufferedReader in = null;
        try {/*  w  ww .  ja v a2 s  .  co  m*/
            in = new BufferedReader(new FileReader(fileName));
            while ((line = in.readLine()) != null) {
                lineList.add(line);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            if (null != in) {
                in.close();
            }
        }
        return lineList;
    }
}

Related

  1. fileToSet(final String dirname, final String filename, final Set set)
  2. getFileContent(File file)
  3. getFileContent(File file, String charSet)
  4. getFileResourceText(String path)