Here you can find the source of writeStringToFile(String content, String filename)
public static void writeStringToFile(String content, String filename) throws IOException
//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(); } } }