Here you can find the source of writeFile(String path, String fileName, String data)
public static void writeFile(String path, String fileName, String data) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void writeFile(String path, String fileName, String data) throws IOException { createPath(path);// w ww. ja va 2s. c om String fullPath = path + fileName; File file = new File(fullPath); if (!file.exists()) { file.createNewFile(); } BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file)); bufferedWriter.write(data); bufferedWriter.close(); } private static void createPath(String path) { File dir = new File(path); if (!(dir.exists())) { dir.mkdirs(); } } }