Here you can find the source of readFile(String file)
public static String readFile(String file)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readFile(String file) { StringBuffer buffer = new StringBuffer(); try {/* w w w. j a v a2 s . com*/ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); while (br.ready()) { buffer.append(br.readLine()).append("\n"); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return buffer.toString(); } }