Here you can find the source of saveTextFile(String contents, File file)
Parameter | Description |
---|---|
contents | The text contents that need to be saved. |
file | The file which the text will be saved to. |
public static void saveTextFile(String contents, File file)
//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) { } } }