Java FileWriter Write saveTextFile(String contents, File file)

Here you can find the source of saveTextFile(String contents, File file)

Description

Saves text to a specified file.

License

Open Source License

Parameter

Parameter Description
contents The text contents that need to be saved.
file The file which the text will be saved to.

Declaration

public static void saveTextFile(String contents, File file) 

Method Source Code

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

import java.io.File;

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

import java.io.PrintWriter;

public class Main {
    /**//w ww. java2 s.  co  m
     * Saves text to a specified file.
     * 
     * @param contents   The text contents that need to be saved.
     * @param file      The file which the text will be saved to.
     */
    public static void saveTextFile(String contents, File file) {
        try {
            PrintWriter out = new PrintWriter(new FileWriter(file));
            out.print(contents);
            out.close();
        } catch (IOException ioe) {

        }
    }
}

Related

  1. saveStringToFile(String text, File fname)
  2. saveTemporaryTermFile(File tempLocation, String word, Collection termList)
  3. saveText(java.io.File f, String text)
  4. saveTextFile(File file, String text)
  5. saveTextFile(String content, File file, boolean append)
  6. saveTextFile(String fileName, String text)
  7. saveToCache(String md, String in, String res)
  8. saveToFile(File file, String string)
  9. saveToFile(File file, String text)