Java Membuat File

import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;

public class ngajaranFile
{
    public static void main(String[]args)
    {
        PrintWriter outputStream = null;
        try
        {
            outputStream = new PrintWriter(new FileOutputStream("cob.rtf"));
        }
        catch(FileNotFoundException e)
        {
            System.out.println("error opening nyoba.exe");
            System.exit(0);
        }
        System.out.println("Writing to file");
        outputStream.println("Saya sedang menulis file baru.");
        outputStream.println("Menulis data baru kedalam file");
        outputStream.close();
        System.out.println("End of program");
    }
}

0 Response to "Java Membuat File"

Posting Komentar