Wednesday, June 27, 2018

input data ke dlm txt


import java.io.*;

class FileOutputDemo {


                public static void main(String args[]){
                                FileOutputStream out; //declare a file output object
                                PrintStream p; //declare a print stream object
                                try{
                                                //create a new file output stream
                                                // connected to "myfile.txt"
                                                out = new FileOutputStream("myfile.txt");
                                                //connect print stream to the output stream
                                                p = new PrintStream(out);
                                                p.println("this is writen to a file");
                                                p.close();
                                }catch (Exception e){
                                                System.err.println("error to writing to filr");
                                }             
                }
}

No comments:

Post a Comment