Here you can find the source of writeFile(String path, String content)
public static boolean writeFile(String path, String content)
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { public static boolean writeFile(String path, String content) { boolean successed = false; OutputStream fos = null;//from ww w. j a va2s .com Writer osw = null; try { File file = new File(path); if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } fos = new FileOutputStream(file); osw = new OutputStreamWriter(fos, "UTF-8"); String newContent = content != null ? content : ""; osw.write(newContent); successed = true; } catch (IOException e) { e.printStackTrace(); } finally { try { osw.close(); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return successed; } }