Here you can find the source of readTextFromFile(String textFilePath)
public static String[] readTextFromFile(String textFilePath)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; public class Main { public static String[] readTextFromFile(String textFilePath) { String[] linesArr = null; Path filePath = Paths.get(textFilePath); Charset charset = Charset.forName("ISO-8859-1"); try {/*w w w. j a va 2s.c o m*/ List<String> lines = Files.readAllLines(filePath, charset); linesArr = new String[lines.size()]; for (int i = 0; i < lines.size(); i++) { linesArr[i] = lines.get(i); } } catch (IOException e) { System.out.println(e); } return linesArr; } }