Here you can find the source of writeFile(File file, String dataString)
Parameter | Description |
---|---|
file | a parameter |
dataString | a parameter |
public static boolean writeFile(File file, String dataString)
//package com.java2s; /**//w w w . j a va 2 s . c om BlackBoard BreadBoard Designer Written and maintained by Matthias Pueski Copyright (c) 2010-2011 Matthias Pueski 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { /** * Writes a string to a file; * * @param file * @param dataString * @return */ public static boolean writeFile(File file, String dataString) { try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file))); out.print(dataString); out.flush(); out.close(); } catch (IOException e) { return false; } return true; } }