Here you can find the source of writeFile(File outputDirectory, String fileName, String source)
public static void writeFile(File outputDirectory, String fileName, String source) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void writeFile(File outputDirectory, String fileName, String source) throws Exception { File path = new File(outputDirectory.getAbsolutePath()); if (!path.exists()) { path.mkdirs();/* w ww .j a v a 2s. c o m*/ } File file = new File(path, fileName); if (!file.exists()) { file.createNewFile(); } System.out.println("Generating: " + file.getAbsolutePath()); try (FileOutputStream fos = new FileOutputStream(file)) { fos.write(source.trim().getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); } } }