Here you can find the source of writeFile(String dir, String file, String content)
public static void writeFile(String dir, String file, String content)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; public class Main { /**/*from www . j a v a2 s.c om*/ * Write 'content' in 'dir'/'file' */ public static void writeFile(String dir, String file, String content) { File newDir = new File(dir); newDir.mkdirs(); try (FileWriter fw = new FileWriter(dir + "/" + file, false); BufferedWriter output = new BufferedWriter(fw);) { output.write(content); output.flush(); output.close(); } catch (Exception e) { e.printStackTrace(); } } }