Java PrintWriter Write saveFile(File f, String text)

Here you can find the source of saveFile(File f, String text)

Description

Given a file to write to, and data to write to it, it will write the data.

License

Open Source License

Parameter

Parameter Description
f file to write to
text text to write to

Declaration


public static void saveFile(File f, String text) 

Method Source Code


//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());
        }
    }
}

Related

  1. save(Map map, String fileName)
  2. save(String fileName, List list)
  3. save(String s, File file)
  4. saveChiPhiTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
  5. saveConvert(final String text, final int escapeMode, final PrintWriter writer)
  6. saveFile(String fileName, String data)
  7. saveFile(String path, String text)
  8. saveHeatmapTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
  9. saveLastExpInfo(String fileName, int[] info)