Here you can find the source of toFile(String fileName, String content)
public static void toFile(String fileName, String content) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void toFile(String fileName, String content) throws IOException { File file = new File(fileName); try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) { bw.write(content);//w w w. j a v a 2s.c o m bw.flush(); } } }