Here you can find the source of readAll(File file)
public static String readAll(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readAll(File file) { try (InputStream in = new FileInputStream(file)) { byte[] bs = new byte[(int) file.length()]; int p = 0, len; while ((len = in.read(bs, p, bs.length - p)) >= 0) p += len;//from w w w. j a v a 2 s . co m if (p != bs.length) throw new RuntimeException(); return new String(bs); } catch (IOException e) { return null; } } public static String read(String file) { return readAll(new File(file)); } }