Android Text File Write writeTextFile(String path, String text)

Here you can find the source of writeTextFile(String path, String text)

Description

Writes the contents of a String to a file.

License

Open Source License

Parameter

Parameter Description
path File to write
text File contents

Exception

Parameter Description
IOException in case of failure

Declaration

public static void writeTextFile(String path, String text)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    /**/*from   w  ww  .j  av  a2s  . c o  m*/
     * Writes the contents of a String to a file.
     * <p>
     * Notes: - file will have the system default encoding
     * 
     * @param path File to write
     * @param text File contents
     * @throws IOException in case of failure
     */
    public static void writeTextFile(String path, String text)
            throws IOException {
        FileWriter writer = new FileWriter(path, false);
        writer.write(text);
        writer.close();
    }
}

Related

  1. writeStringToFile(String content, String fileName, boolean append)
  2. writeStringToFile(String string, File file)
  3. writeStringToFile(String stringToWrite, String filename)
  4. writeText(File file, String text)
  5. writeText(File file, String text, String charsetName)
  6. writeTextFile(String string, String fileName)
  7. writeTextToFile(String file, String text)
  8. writeToFile(File file, String content)
  9. writeToFile(File target, String s, String charSet)