Java InputStreamReader Read readFile(String filePath)

Here you can find the source of readFile(String filePath)

Description

readFile

License

Apache License

Parameter

Parameter Description
filePath a parameter

Declaration

public static List readFile(String filePath) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.FileInputStream;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;

public class Main {
    /**/*from w ww.ja  v a  2s .  co m*/
     * readFile 
     * @param filePath
     * @return
     */
    public static List readFile(String filePath) {

        try {
            File file = new File(filePath);
            FileInputStream fis = new FileInputStream(file);
            BufferedReader br = new BufferedReader(new InputStreamReader(fis));
            // read lines
            List rowList = new ArrayList();
            String line = "";
            while ((line = br.readLine()) != null) {
                rowList.add(line);
            }
            // done 
            return rowList;
        } catch (Exception e) {
            e.printStackTrace();
            return new ArrayList();
        }
    }
}

Related

  1. readFile(String fileName, String characterEncoding)
  2. readFile(String fileName, String charSet)
  3. readFile(String fileName, String coloredLineIndicator, boolean useSections, boolean isXML)
  4. readFile(String filename1)
  5. readFile(String fileNm)
  6. readFile(String filePath)
  7. readFile(String filePath)
  8. readFile(String filePath)
  9. readFile(String filePath)