Here you can find the source of saveFile(File f, String text)
Parameter | Description |
---|---|
f | file to write to |
text | text to write to |
public static void saveFile(File f, String text)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/* w ww. jav a 2s.c o m*/ * Given a file to write to, and data to write to it, * it will write the data. * If there are _any_ issues, simply writes an error message. * SIDE EFFECT: Writes data to specified file. * @param f file to write to * @param text text to write to */ public static void saveFile(File f, String text) { try (PrintWriter out = new PrintWriter(f)) { out.println(text); } catch (IOException ioex) { System.out.println("Could not write to file " + f.toString()); } } }