Here you can find the source of writeFile(String path, String contents)
public static void writeFile(String path, String contents)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void writeFile(String path, String contents) { Path p = FileSystems.getDefault().getPath(path); writeFile(p, contents);// w ww.ja v a 2 s .c om } public static void writeFile(Path p, String contents) { try { Files.deleteIfExists(p); Files.write(p, contents.getBytes()); } catch (IOException e) { throw new RuntimeException(e); } } }