Here you can find the source of fileWrite(String filePath, String fileName, String content)
public static void fileWrite(String filePath, String fileName, String content) throws Exception
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; public class Main { public static void fileWrite(String filePath, String fileName, String content) throws Exception { if (filePath.endsWith("/")) { filePath = filePath.substring(0, filePath.length() - 1); }/*from w w w . j a v a 2 s .c om*/ File dest = new File(filePath); if (!dest.exists()) { dest.mkdirs(); } try { File file = new File(filePath + "/" + fileName); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); if (content != null) { writer.write(content); } writer.flush(); writer.close(); } catch (FileNotFoundException e) { throw new Exception(e); } catch (IOException e) { throw new Exception(e); } } }