Here you can find the source of writeStringToFile(String file, String data, boolean append)
Parameter | Description |
---|---|
file | the file |
data | the data |
append | the append |
public static void writeStringToFile(String file, String data, boolean append)
//package com.java2s; /*/*from w ww.j ava 2 s.c om*/ This file is part of PSFj. PSFj 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. PSFj 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 PSFj. If not, see <http://www.gnu.org/licenses/>. Copyright 2013,2014 Cyril MONGIS, Patrick Theer, Michael Knop */ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class Main { /** * Write string to file. * * @param file the file * @param data the data * @param append the append */ public static void writeStringToFile(String file, String data, boolean append) { FileWriter fstream; try { fstream = new FileWriter(file, append); BufferedWriter out = new BufferedWriter(fstream); out.write(data); out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }