Java FileWriter Write saveStringFile(String fileName, String str)

Here you can find the source of saveStringFile(String fileName, String str)

Description

Save a file

License

Open Source License

Declaration

public static boolean saveStringFile(String fileName, String str) 

Method Source Code

//package com.java2s;
/*//from  w ww . java  2 s .c  om
 * ArikTools
 * Copyright (C) Arik Z.Lakritz, Peter Macko, and David K. Wittenberg
 * 
 * This file is part of ArikTools.
 *
 * ArikTools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ArikTools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ArikTools.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.*;

public class Main {
    /**
     * Save a file
     */
    public static boolean saveStringFile(String fileName, String str) {
        File f = new File(fileName);
        try {
            PrintWriter w = new PrintWriter(new FileWriter(f));
            w.print(str);
            w.close();
        } catch (java.io.IOException e) {
            System.err.println(e);
            return false;
        }
        return true;
    }
}

Related

  1. saveSimpleTextFile(String data, String path, String filename)
  2. saveStats(String filename, String log)
  3. saveString(File filename, String content)
  4. saveString(String filePath, String content)
  5. saveString(String location, String content)
  6. saveStringInFile(String filePath, String data)
  7. saveStringToDisc(final String params, final String filePath)
  8. saveStringToFile(String content, File destFile)
  9. saveStringToFile(String filePath, String content, boolean isOverwrite)