Here you can find the source of writeFile(File target, String content)
public static void writeFile(File target, String content)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void writeFile(File target, String content) { PrintWriter p = null;/*from w w w. j a v a 2 s . co m*/ try { p = new PrintWriter(new FileWriter(target)); p.write(content); } catch (Exception e) { throw new RuntimeException("Problems writing text to file: " + target); } finally { close(p); } } /** * Closes the target. Does nothing when target is null. Is not silent, throws exception on IOException. * * @param closeable the target, may be null */ public static void close(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { throw new RuntimeException("Problems closing stream", e); } } } }