Here you can find the source of readAllText(String path)
@SuppressWarnings("null") public static String readAllText(String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { @SuppressWarnings("null") public static String readAllText(String path) throws IOException { File file = new File(path); BufferedReader br = null; StringBuilder sb = new StringBuilder(); try {//from ww w . j a v a 2 s .c o m String line; br = new BufferedReader(new FileReader(file)); while ((line = br.readLine()) != null) { sb.append(line + '\n'); } } catch (IOException e) { try { br.close(); } catch (NullPointerException e2) { } throw e; } br.close(); return sb.toString(); } }