Java BufferedWriter Write writeFile(String dir, String file, String content)

Here you can find the source of writeFile(String dir, String file, String content)

Description

Write 'content' in 'dir'/'file'

License

Open Source License

Declaration

public static void writeFile(String dir, String file, String content) 

Method Source Code

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

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

public class Main {
    /**/*from www .  j  a  v  a2  s.c om*/
     * Write 'content' in 'dir'/'file'
     */
    public static void writeFile(String dir, String file, String content) {
        File newDir = new File(dir);
        newDir.mkdirs();

        try (FileWriter fw = new FileWriter(dir + "/" + file, false);
                BufferedWriter output = new BufferedWriter(fw);) {
            output.write(content);
            output.flush();
            output.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeFile(BufferedWriter fw, String line)
  2. writeFile(double[][] toWrite, String outName)
  3. writeFile(File dir, File fileRef, File newFileName, ClassLoader classLoader)
  4. writeFile(File src, File dst)
  5. writeFile(Object msg)
  6. writeFile(String directory, String content, String fileName, boolean deleteFileBeforeWriting)
  7. WriteFile(String file)
  8. writeFile(String file, List data)
  9. writeFile(String filename, ArrayList entries)