Here you can find the source of saveStringBufferTofile(String fileName, StringBuffer sb)
public static void saveStringBufferTofile(String fileName, StringBuffer sb) throws FileNotFoundException, UnsupportedEncodingException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void saveStringBufferTofile(String fileName, StringBuffer sb) throws FileNotFoundException, UnsupportedEncodingException { PrintWriter writer = new PrintWriter(fileName, "UTF-8"); try {//from w w w. j a v a 2 s . co m writer.println(sb); writer.close(); } finally { writer.close(); } } }