Minggu, 14 November 2010

java tulis ke file

import java.io.*;

class WriteToFile
{
public static void main(String args[])
{
try{

// Membuat sebuah file
FileWriter fs = new FileWriter("hasil.txt");
BufferedWriter out = new BufferedWriter(fs);
out.write("Hello World");

//menutup stream output
out.close();

}catch (Exception e){ //Catch exception jika ada
System.err.println("Error: " + e.getMessage());
}
}
}

Tidak ada komentar:

Posting Komentar