Here you can find the source of readFile(String path)
public static String readFile(String path) 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 readFile(String path) throws IOException { File file = new File(path); FileInputStream fis = new FileInputStream(file); byte[] data = new byte[(int) file.length()]; fis.read(data);//from w w w.j a v a 2s . c o m fis.close(); return new String(data, "UTF-8"); } }