Java FileReader Create readTextFile(String filePath)

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

Description

read Text File

License

Apache License

Declaration

public static String[] readTextFile(String filePath) throws IOException 

Method Source Code

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

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;
import java.util.ArrayList;

public class Main {
    public static String[] readTextFile(String filePath) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(filePath));
        ArrayList<String> fileContents = new ArrayList<String>();
        String line = br.readLine();
        while (line != null) {
            fileContents.add(line);/*from   w  w w  .j  a  va  2s  . com*/
            line = br.readLine();
        }
        br.close();

        return fileContents.toArray(new String[fileContents.size()]);
    }
}

Related

  1. readTextFile(String fileName)
  2. readTextFile(String filename)
  3. readTextFile(String filename)
  4. readTextFile(String fileName, boolean newline)
  5. readTextFile(String fileName, String enc)
  6. readTextFile(String filePath)
  7. readTextFile(String filePath)
  8. readTextFile(String fullPathFilename)
  9. readTextFile(String path)