Here you can find the source of toFile(Path file, String list)
public static void toFile(Path file, String list) throws IOException
//package com.java2s; //License from project: Open Source License import java.nio.file.Path; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void toFile(Path file, String list) throws IOException { FileOutputStream fos = null; try {/*from w w w . j av a 2s . com*/ fos = new FileOutputStream(file.toString()); fos.write(list.getBytes()); fos.flush(); } finally { if (fos != null) fos.close(); } } }