Here you can find the source of writeTo(File file, String content)
public static void writeTo(File file, String content) throws IOException
//package com.java2s; //License from project: Open Source License import java.util.*; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; public class Main { public static void writeTo(Path path, String content) throws IOException { //not intended for writing in large files. //Files.write(path, content.getBytes(Charset.defaultCharset()), StandardOpenOption.WRITE); Files.write(path, Arrays.asList(content), Charset.defaultCharset(), StandardOpenOption.WRITE); }//from ww w. j a v a 2 s .c o m public static void writeTo(File file, String content) throws IOException { Path path = file.toPath(); writeTo(path, content); } }