Here you can find the source of readStringFromFile(File file)
public static String readStringFromFile(File file)
//package com.java2s; import java.io.File; import java.io.FileReader; public class Main { public static String readStringFromFile(File file) { FileReader reader = null; try {//from ww w .j a va2s . c o m reader = new FileReader(file); StringBuffer stringBuffer = new StringBuffer(); char[] buffer = new char[1024]; int count = 0; while ((count = reader.read(buffer)) != -1) { stringBuffer.append(buffer, 0, count); } reader.close(); return stringBuffer.toString(); } catch (Exception e) { } return null; } }