Java Text File Save writeFile(File path, File file, String content)

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

Description

Write content to file using BufferedWriter.

License

Open Source License

Parameter

Parameter Description
file a parameter
content a parameter

Declaration


public static void writeFile(File path, File 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;
import java.io.IOException;

public class Main {
    /**/*from   w  w w  .  ja va  2  s .  c o m*/
     * Write <code>content</code> to <code>file</code> using BufferedWriter.
     * @param file
     * @param content
     */

    public static void writeFile(File path, File file, String content) {
        try {
            if (!path.isDirectory()) {
                path.mkdir();
            }
            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            writer.write(content);
            writer.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Related

  1. writeFile(File destinationFile, String contents, String encoding)
  2. writeFile(File outputDirectory, String fileName, String source)
  3. writeFile(File outputFile, ArrayList sortedLines, String lineSeparator)
  4. writeFile(File outputFile, String text)
  5. writeFile(File outputFolder, String fileName, String content)
  6. writeFile(File path, String fileName, String fileContent)
  7. writeFile(File target, String content)
  8. writeFile(final byte[] content, final String path)
  9. writeFile(final File destination, final List contents)