Here you can find the source of fileToStringBuffer(File file)
public static StringBuffer fileToStringBuffer(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static StringBuffer fileToStringBuffer(File file) throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); StringBuffer sb = new StringBuffer(); try {/*from w w w. ja v a 2 s. co m*/ String s = null; while ((s = br.readLine()) != null) { sb.append(s + "\n"); } } finally { br.close(); } return sb; } }