Java PrintWriter Write saveFile(String fileName, String data)

Here you can find the source of saveFile(String fileName, String data)

Description

save File

License

Open Source License

Declaration

public static void saveFile(String fileName, String data) 

Method Source Code

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

import java.io.FileNotFoundException;

import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class Main {
    public static void saveFile(String fileName, String data) {
        PrintWriter writer = null;
        try {//w ww . j a  v  a 2s.co  m
            writer = new PrintWriter(fileName, "UTF-8");
            writer.print(data);
        } catch (FileNotFoundException | UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            if (writer != null)
                writer.close();
        }
    }
}

Related

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