Thursday, July 21, 2011

Menulis dan Menyimpan File ke dalam txt (FileStream)

package lalala;

import java.io.*;
public class XXX {



        public static void main(String[] args) {
            FileOutputStream fos;
            DataOutputStream dos;
            try {
                File file= new File("coba.txt");
                fos = new FileOutputStream(file);
               dos=new DataOutputStream(fos);
               dos.writeBytes("Hello Java");
           } catch (IOException e) {
               e.printStackTrace();
           }
       }
   }



coba.txt nya di dalam project kalian
ex :
C:\Documents and Settings\User\My Documents\NetBeansProjects\Streaming


^^

No comments:

Post a Comment