Here you can find the source of readFile(String filename)
public static String readFile(String filename) throws IllegalArgumentException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String readFile(String filename) throws IllegalArgumentException { String fileContents = ""; File file = new File(filename); if (!file.exists() || !file.isFile()) throw new IllegalArgumentException(); try (FileInputStream stream = new FileInputStream(file)) { byte[] fileBytes = new byte[(int) file.length()]; stream.read(fileBytes, 0, (int) file.length()); //throw new IllegalArgumentException(); fileContents = new String(fileBytes); } catch (IOException ex) { System.err.println(ex.getMessage()); System.exit(-1);// w w w . j a va 2 s. c o m } return fileContents; } }