Here you can find the source of readTextFile(String filePath)
public static String[] readTextFile(String filePath) throws IOException
//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()]); } }