Java OutputStreamWriter Write save(String text, File out)

Here you can find the source of save(String text, File out)

Description

Creates file with given text

License

Open Source License

Parameter

Parameter Description
text text of the file
out file location

Exception

Parameter Description
IOException IO errors

Declaration

public static void save(String text, File out) throws IOException 

Method Source Code


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

import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class Main {
    /**/*w w  w  .j  a v  a2 s  .com*/
    * Creates file with given text
    * @param text text of the file
    * @param out file location
    * @throws IOException IO errors
    */
    public static void save(String text, File out) throws IOException {
        BufferedWriter bw = new BufferedWriter(
                new OutputStreamWriter(new DataOutputStream(new FileOutputStream(out))));
        bw.write(text);
        bw.close();
    }
}

Related

  1. save(String fileContent, File file, String encoding)
  2. saveCache()
  3. saveDocument(String path, String textToWrite)
  4. saveFile(File file, String whatToSave, String encoding)
  5. saveFile(final File file, final String content)