Java BufferedWriter Write WriteFile(String file)

Here you can find the source of WriteFile(String file)

Description

Write File

License

Open Source License

Declaration

public static void WriteFile(String file) 

Method Source Code

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

import java.io.BufferedWriter;

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

public class Main {
    public static void WriteFile(String file) {
        // Menulis ke file
        try {//from  www .  j a  va  2s  .c o m
            BufferedWriter out = new BufferedWriter(new FileWriter(file));
            out.write("Halo Indonesia");
            out.write("\nBaris baru");
            // Ini juga menghasilkan baris baru
            out.newLine();
            out.write("Apa kabar?");
            // Menutup stream dan melepaskan resource
            out.close();
            System.out.println("ok");
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }

    }
}

Related

  1. writeFile(File dir, File fileRef, File newFileName, ClassLoader classLoader)
  2. writeFile(File src, File dst)
  3. writeFile(Object msg)
  4. writeFile(String dir, String file, String content)
  5. writeFile(String directory, String content, String fileName, boolean deleteFileBeforeWriting)
  6. writeFile(String file, List data)
  7. writeFile(String filename, ArrayList entries)
  8. writeFile(String filename, Map map)
  9. writeFile(String line, File file)