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

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

Description

write File

License

Open Source License

Declaration

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

Method Source Code


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

import java.io.*;

public class Main {
    public static void writeFile(File f, String str) throws IOException {
        FileOutputStream fos = new FileOutputStream(f);
        try {//  w  w  w. j a v  a2  s  .c  o  m
            fos.write(str.getBytes("UTF-8"));
            fos.flush();
        } finally {
            fos.close();
        }
    }
}

Related

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