Here you can find the source of readAllText(final String filename)
public static String readAllText(final String filename) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String readAllText(final String filename) throws IOException { FileInputStream fis = null; try {/*from w w w .j a v a 2 s. c om*/ File file = new File(filename.toString()); fis = new FileInputStream(file); int size = fis.available(); byte[] contents = new byte[size]; fis.read(contents); return new String(contents); } catch (Exception e) { throw new IOException(e); } finally { // in the absence of commons io, this workaround is needed to close the file if (fis != null) { try { fis.close(); } catch (IOException e) { // ignore } } } } }