Here you can find the source of WriteFile(String filepath, String content)
public static boolean WriteFile(String filepath, String content)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static boolean WriteFile(String filepath, String content) { File outputFile = new File(filepath); if (outputFile.exists()) { outputFile.delete();//from w ww . j a v a 2 s. co m } File parentDirectory = outputFile.getParentFile(); if (parentDirectory != null && !parentDirectory.exists()) { parentDirectory.mkdirs(); } // Write to file BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(filepath)); writer.write(content); return true; } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { } } } return false; } }