Tuesday, March 22, 2011

2 inputan data ke dlm txt


 import java.io.*;

class InputData {
                public static void main (String []args){
                                FileOutputStream out;
                                PrintStream p;
                                try {
                                                out = new FileOutputStream("data.txt");
                                                p = new PrintStream(out);
                                                System.out.print("nama : ");
                                                BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
                                                p.print(b.readLine()+",");
                                                System.out.print("alamat : ");
                                                BufferedReader c = new BufferedReader (new InputStreamReader(System.in));
                                                p.print(c.readLine());
                                }catch (Exception e){
                                                System.err.println("error writing to file");
                                }
                }
}

No comments:

Post a Comment