Google+ Followers

Connect

Get Updates Via Email

Enter your email address:

Delivered by FeedBurner

Monday, 11 November 2013

Java Program: File I/O Fileoutputstream to create file

Program

import java.io.*;
public class createfile {
    public static void main(String[] args)
    {
        try
        {
        createfile();
        }
        catch(Exception ex)
        {
            System.out.println("File Exceptio occured");
        }    
    }
    public static void createfile() throws java.io.IOException
    {
        DataInputStream d=new DataInputStream(System.in);
        FileOutputStream f=new FileOutputStream("jack.txt",true);
        BufferedOutputStream b=new BufferedOutputStream(f,1024);
        System.out.println("Enter $ at the end to finish text");
        char c;
        while((c=(char)d.read())!='$')
        {
            b.write(c);          
        }
        b.close();
    }

}

Output



1 comment :

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

    ReplyDelete

Share this to your friends