Java Write String to File writeFile(File f, String text)

Here you can find the source of writeFile(File f, String text)

Description

write File

License

Apache License

Declaration

public static void writeFile(File f, String text) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static void writeFile(File f, String text) throws IOException {
        FileWriter fileWriter = null;
        BufferedWriter bufferedWriter = null;

        try {/*from  w  ww .j  av  a 2 s.co m*/
            fileWriter = new FileWriter(f);
            bufferedWriter = new BufferedWriter(fileWriter);
            bufferedWriter.write(text);
        } finally {
            if (bufferedWriter != null)
                bufferedWriter.close();
            if (fileWriter != null)
                fileWriter.close();
        }

    }
}

Related

  1. writeFile(File f, String contents)
  2. writeFile(File f, String entry)
  3. writeFile(File f, String s)
  4. writeFile(File f, String str)
  5. writeFile(File f, String str)
  6. writeFile(File file, Iterable lines)
  7. writeFile(File file, String content)
  8. writeFile(File file, String content)
  9. writeFile(File file, String content)