Here you can find the source of writeFile(String path, String contents)
public static void writeFile(String path, String contents) throws Exception
//package com.java2s; /**//from ww w . ja v a 2 s .c o m * Copyright 2009, Google Inc. All rights reserved. * Licensed to PSF under a Contributor Agreement. */ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.PrintWriter; public class Main { public static void writeFile(String path, String contents) throws Exception { PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter(path))); out.print(contents); out.flush(); } finally { if (out != null) { out.close(); } } } }