Here you can find the source of writeToFile(String filename, String... lines)
public static boolean writeToFile(String filename, String... lines)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static boolean writeToFile(String filename, String... lines) { Path p = Paths.get(filename); try (BufferedWriter bw = new BufferedWriter(Files.newBufferedWriter(p))) { for (String l : lines) { bw.write(l);//ww w.jav a 2 s.c om bw.newLine(); } } catch (IOException ex) { return false; } return true; } }