Here you can find the source of writeStringToFile(String filename, String string)
Parameter | Description |
---|---|
filename | a parameter |
string | a parameter |
Parameter | Description |
---|---|
FileNotFoundException | an exception |
IOException | an exception |
public static void writeStringToFile(String filename, String string) throws FileNotFoundException, IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2006 The Board of Trustees of Stanford University. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU General Public License * which is available at http://www.gnu.org/licenses/gpl.txt. *******************************************************************************/ import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; public class Main { /**/* w w w . java2 s . co m*/ * Writes a string to a file. * * @param filename * @param string * @throws FileNotFoundException * @throws IOException */ public static void writeStringToFile(String filename, String string) throws FileNotFoundException, IOException { BufferedWriter out = new BufferedWriter(new FileWriter(filename)); out.write(string); out.close(); } }