Here you can find the source of saveStringToFile(String filePath, String content, boolean isOverwrite)
public static boolean saveStringToFile(String filePath, String content, boolean isOverwrite) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static boolean saveStringToFile(String filePath, String content, boolean isOverwrite) throws FileNotFoundException { File file = new File(filePath); if (file.exists()) { if (isOverwrite) { //noinspection ResultOfMethodCallIgnored file.delete();//from w w w . j a v a 2 s . c o m } else { return false; } } boolean saved = false; try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) { bufferedWriter.write(content); saved = true; } catch (IOException e1) { e1.printStackTrace(); } return saved; } }