Java tutorial
//package com.java2s; //License from project: Apache License import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; public class Main { public static boolean writeFile(StringBuffer sb, String fileName, String path) { String string; DataOutputStream bfo = null; File fileDir = new File(path); if (!fileDir.exists()) fileDir.mkdirs(); try { string = sb.substring(0); bfo = new DataOutputStream(new FileOutputStream(path + fileName)); bfo.write(string.getBytes("gbk")); } catch (Exception ex) { ex.printStackTrace(); } return true; } }