Here you can find the source of readFileAsString(String path)
public static List<String> readFileAsString(String path) throws Exception
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> readFileAsString(String path) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path)))); try {// w ww . jav a 2 s . c o m List<String> list = new ArrayList<>(); String line = reader.readLine(); while (line != null) { list.add(line); line = reader.readLine(); } return list; } finally { if (reader != null) { reader.close(); } } } }