Here you can find the source of writeToFile(String s, Path file)
public static void writeToFile(String s, Path file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void writeToFile(String s, Path file) throws IOException { BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8); writer.append(s);//from w w w . j a va2 s . co m writer.close(); } }