Here you can find the source of readAll(File file)
public static String readAll(File file) throws FileNotFoundException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static String readAll(File file) throws FileNotFoundException { StringBuilder builder = new StringBuilder(); FileInputStream intput = new FileInputStream(file); Scanner scanner = new Scanner(intput, "UTF-8"); while (scanner.hasNextLine()) { builder.append(scanner.nextLine()); builder.append("\n"); }/*w w w .jav a2 s.c o m*/ scanner.close(); return builder.toString(); } }