Java FileWriter Write saveTextFile(String content, File file, boolean append)

Here you can find the source of saveTextFile(String content, File file, boolean append)

Description

Create a file with name and extension based on file argument in a directory and with a content

License

Open Source License

Parameter

Parameter Description
content - content that file may contain #param directory - directory to save the file in
file - the name and extension of the file

Exception

Parameter Description
IOException an exception

Return

What?

Declaration

public static boolean saveTextFile(String content, File file, boolean append) throws IOException 

Method Source Code

//package com.java2s;
/**//from w  w  w  .ja v  a  2  s . c om
 * Visual Tracer - An Application of Java Code Instrumentation using AspectJ 
 * Copyright (C) 2010  
 * Carlos Correia - mail.cefc@gmail.com 
 * Rute Oliveira - rute23@gmail.com
 * Manuel Menezes de Sequeira - manuel.sequeira@iscte.pt
 * 
 * This program 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.
 *  
 *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.BufferedWriter;
import java.io.File;

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

public class Main {
    /**
     * Create a file with name and extension based on file argument in a directory and with a content
     * @param content - content that file may contain
     * #param directory - directory to save the file in
     * @param file - the name and extension of the file
     * @return What?
     * @throws IOException 
     */
    public static boolean saveTextFile(String content, File file, boolean append) throws IOException {
        boolean response = true;
        BufferedWriter out = new BufferedWriter(new FileWriter(file, append));
        out.write(content);
        out.close();
        return response;
    }
}

Related

  1. saveStringToFile(String string, String fileName)
  2. saveStringToFile(String text, File fname)
  3. saveTemporaryTermFile(File tempLocation, String word, Collection termList)
  4. saveText(java.io.File f, String text)
  5. saveTextFile(File file, String text)
  6. saveTextFile(String contents, File file)
  7. saveTextFile(String fileName, String text)
  8. saveToCache(String md, String in, String res)
  9. saveToFile(File file, String string)