Here you can find the source of writeFile(final File file, final String contents)
protected static void writeFile(final File file, final String contents) throws IOException
//package com.java2s; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { protected static void writeFile(final File file, final String contents) throws IOException { final File dir = file.getParentFile(); if (dir != null && !dir.isDirectory() && !dir.mkdirs()) throw new IOException("Could not make " + dir); final FileWriter writer = new FileWriter(file); writer.write(contents);//from w w w .ja va 2s . c om writer.close(); } }