Java FileWriter Write saveFile(File file, String data)

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

Description

Saves the String data to the File.

License

Apache License

Parameter

Parameter Description
file The location to save the String.
data The String data to save.

Exception

Parameter Description
IOException an exception

Declaration

public static final void saveFile(File file, String data) throws IOException 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.io.File;

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    /**//www.  ja v a  2s .co  m
     * Saves the String data to the File.
     * 
     * @param file The location to save the String.
     * @param data The String data to save.
     * @throws IOException
     */
    public static final void saveFile(File file, String data) throws IOException {
        FileWriter writer = null;
        try {
            writer = new FileWriter(file);
            writer.write(data);
        } catch (IOException e) {
            throw e;
        } finally {
            writer.close();
        }
    }
}

Related

  1. saveDoubleArray2File(Double[] doubleArray, String fileName)
  2. saveDoubleArray2FileAppend(Double[] doubleArray, String fileName)
  3. saveEasyQuestImpl(final String quest, final File targetFile)
  4. saveFile(File directory, String fileName, String content)
  5. saveFile(File file, String contents)
  6. saveFile(File file, String fileContent)
  7. saveFile(File file, String text, boolean append)
  8. saveFile(List contents, String fileName)
  9. saveFile(String filePath, String content)