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

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

Description

Writes a string to a file.

License

Open Source License

Parameter

Parameter Description
filename a parameter
string a parameter

Exception

Parameter Description
FileNotFoundException an exception
IOException an exception

Declaration

public static void writeStringToFile(String filename, String string) throws FileNotFoundException, IOException 

Method Source Code

//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();
    }
}

Related

  1. writeStringToFile(String fileName, String content)
  2. writeStringToFile(String filename, String content)
  3. writeStringToFile(String fileName, String src)
  4. writeStringToFile(String filename, String str)
  5. writeStringToFile(String fileName, String str, boolean isAppend)
  6. writeStringToFile(String filename, String string, boolean overwrite)
  7. writeStringToFile(String filename, String stringToWrite)
  8. writeStringToFile(String filename, String text)
  9. WriteStringToFile(String fn, String dest)