Java Text File Write writeStringToFile(String str, File file)

Here you can find the source of writeStringToFile(String str, File file)

Description

write String To File

License

LGPL

Declaration

public static void writeStringToFile(String str, File file) 

Method Source Code

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

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

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

public class Main {
    public static void writeStringToFile(String str, File file) {
        BufferedWriter writer = null;
        try {//  w w  w.  j ava  2 s.  c o m
            file.delete();
            file.createNewFile();
            writer = new BufferedWriter(new FileWriter(file));
            writer.write(str);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (writer != null)
                    writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. writeStringToFile(String s, File f)
  2. writeStringToFile(String s, File file)
  3. writeStringToFile(String s, String filename)
  4. writeStringToFile(String s, String filePathname)
  5. writeStringToFile(String sdat, File f)
  6. writeStringToFile(String str, File file)
  7. writeStringToFile(String str, File file)
  8. WriteStringToFile(String str, String file)
  9. writeStringToFile(String str, String filePath)