Here you can find the source of writeFileContents(File file, String content)
public static void writeFileContents(File file, String content) throws Exception
//package com.java2s; import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.StandardOpenOption; public class Main { public static void writeFileContents(File file, String content) throws Exception { writeFileContents(file, content, Boolean.TRUE); }// w ww .ja v a 2s .c o m private static void writeFileContents(File file, String content, boolean newFile) throws Exception { if (file != null && content != null) { try { Files.write(FileSystems.getDefault().getPath(file.getPath()), content.getBytes(), (newFile ? StandardOpenOption.CREATE : StandardOpenOption.TRUNCATE_EXISTING)); return; } catch (IOException ioe) { throw ioe; } } throw new Exception("Invalid or incomplete parameters."); } }