Java FileWriter Write saveStringToFile(String fileToSave, String data)

Here you can find the source of saveStringToFile(String fileToSave, String data)

Description

save String To File

License

Open Source License

Declaration

public static boolean saveStringToFile(String fileToSave, String data) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class Main {
    public static boolean saveStringToFile(String fileToSave, String data) {
        Writer fw = null;/*  ww w  .j av  a 2 s .  co m*/
        try {
            fw = new FileWriter(fileToSave);
            fw.write(data);
            fw.append('\n');
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        } finally {
            if (fw != null)
                try {
                    fw.close();
                } catch (IOException e) {
                }
        }
        return true;
    }
}

Related

  1. saveStringFile(String fileName, String str)
  2. saveStringInFile(String filePath, String data)
  3. saveStringToDisc(final String params, final String filePath)
  4. saveStringToFile(String content, File destFile)
  5. saveStringToFile(String filePath, String content, boolean isOverwrite)
  6. saveStringToFile(String string, String fileName)
  7. saveStringToFile(String text, File fname)
  8. saveTemporaryTermFile(File tempLocation, String word, Collection termList)
  9. saveText(java.io.File f, String text)