Here you can find the source of WriteFile(String file)
public static void WriteFile(String file)
//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()); } } }