Java Text File Write writeStringToFile(String content, String filename)

Here you can find the source of writeStringToFile(String content, String filename)

Description

write String To File

License

Open Source License

Declaration

public static void writeStringToFile(String content, String filename) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 Daniel Murygin <dm[at]sernet[dot]de>.
 * This program is free software: you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
 *     You should have received a copy of the GNU Lesser General Public 
 * License along with this program. /*from   w w w.  j a  v  a 2s  .  c o m*/
 * If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 *     Daniel <dm[at]sernet[dot]de> - initial API and implementation
 ******************************************************************************/

import java.io.BufferedWriter;

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

public class Main {
    public static void writeStringToFile(String content, String filename) throws IOException {
        BufferedWriter writer = null;
        writer = new BufferedWriter(new FileWriter(filename));
        writer.write(content);

        if (writer != null) {
            writer.close();
        }
    }
}

Related

  1. writeStringToFile(String content, File file)
  2. writeStringToFile(String content, File file)
  3. writeStringToFile(String content, File outputfile)
  4. writeStringToFile(String content, File targetFile)
  5. writeStringToFile(String content, String encoding, String fileName)
  6. writeStringToFile(String content, String filename)
  7. writeStringToFile(String content, String fileName)
  8. writeStringToFile(String content, String filename)
  9. writeStringToFile(String content, String fileName, boolean append)