Here you can find the source of writeFile(File file, String content)
public static void writeFile(File file, String content) throws IOException
//package com.java2s; /*/*from www. j av a2 s. c om*/ * Copyright (c) 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM - initial API and implementation * * $Id: BuildUtil.java,v 1.3 2007/02/22 08:40:26 asobolev Exp $ */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void writeFile(File file, String content) throws IOException { if (!file.getParentFile().isDirectory()) { file.getParentFile().mkdirs(); } BufferedWriter out = null; try { out = new BufferedWriter(new FileWriter(file)); out.write(content); } finally { if (out != null) { out.close(); } } } }