Android Text File Write writeTextToFile(String file, String text)

Here you can find the source of writeTextToFile(String file, String text)

Description

Simple method to write text to a file

License

Open Source License

Parameter

Parameter Description
file The filename (with full path) to write to
text Text to write to the file

Declaration

public static final void writeTextToFile(String file, String text) 

Method Source Code

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

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.IOException;

public class Main {
    /**/* w  ww .  j a v a2s  .co  m*/
     * Simple method to write text to a file
     * @param file The filename (with full path) to write to
     * @param text Text to write to the file
     */
    public static final void writeTextToFile(String file, String text) {
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            writer.write(text);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

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