Java File Content Read getFileContent(String path)

Here you can find the source of getFileContent(String path)

Description

get File Content

License

Apache License

Declaration

public static List<String> getFileContent(String path) 

Method Source Code

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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;

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

public class Main {

    public static List<String> getFileContent(String path) {
        List<String> strList = new ArrayList<String>();
        try {/*from  ww  w. ja v  a 2  s .  c  om*/
            File file = new File(path);
            InputStreamReader read = new InputStreamReader(new FileInputStream(file), "UTF-8");
            BufferedReader reader = new BufferedReader(read);
            String line;
            while ((line = reader.readLine()) != null) {
                strList.add(line);
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return strList;
    }
}

Related

  1. getFileContent(String fileName)
  2. getFileContent(String filePath)
  3. getFileContent(String filePath)
  4. getFileContent(String filepath)
  5. getFileContent(String fName)
  6. getFileContent(String path)
  7. getFileContent(String path)
  8. getFileContent(String path)
  9. getFileContent(String path)