Here you can find the source of readFile(String fileName)
public static String readFile(String fileName)
//package com.java2s; //This product is provided under the terms of EPL (Eclipse Public License) import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; public class Main { public static String readFile(String fileName) { try {//from www .jav a 2s. co m File file = new File(fileName); BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); byte[] bytes = new byte[(int) file.length()]; stream.read(bytes); return new String(bytes); } catch (Exception e) { throw new RuntimeException(e); } } }