read File using Reader and return list of String - Android File Input Output

Android examples for File Input Output:Text File

Description

read File using Reader and return list of String

Demo Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> readFile(Reader simpleReader)
            throws IOException {
        BufferedReader reader = new BufferedReader(simpleReader);
        try {// w  ww .j  a  v  a2 s  . c om
            List<String> res = new ArrayList<String>();
            String line;
            while ((line = reader.readLine()) != null) {
                res.add(line);
            }
            return res;
        } finally {
            reader.close();
        }
    }
}

Related Tutorials