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
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
Comments
Post a Comment
Share this to your friends