Here you can find the source of writeFile(final File file, final String content)
static File writeFile(final File file, final String content)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { static File writeFile(final File file, final String content) { try {/* w w w . j ava2s.c o m*/ if (file.exists()) { file.delete(); } final File parent = file.getParentFile(); if (!parent.exists()) { parent.mkdirs(); } final FileWriter fw = new FileWriter(file); fw.write(content); fw.close(); return file; } catch (final IOException e) { throw new RuntimeException("Error in tests!", e); } } }