package FileHandling;
import java.io.DataInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileCreation {
public static void main(String[] args) {
DataInputStream dis=null;
FileOutputStream fout=null;
try
{
dis=new DataInputStream(System.in);
fout=new FileOutputStream("as.txt",true);
System.out.println("Enter the text to be saved in file.Enter $ to end the text");
char ch;
while((ch=(char)dis.read())!='$')
{
fout.write(ch);
}
}catch(IOException ie)
{
ie.printStackTrace();
}
finally
{
try
{
dis.close();
fout.close();
}catch(IOException ie)
{
ie.printStackTrace();
}
}
}
}
import java.io.DataInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileCreation {
public static void main(String[] args) {
DataInputStream dis=null;
FileOutputStream fout=null;
try
{
dis=new DataInputStream(System.in);
fout=new FileOutputStream("as.txt",true);
System.out.println("Enter the text to be saved in file.Enter $ to end the text");
char ch;
while((ch=(char)dis.read())!='$')
{
fout.write(ch);
}
}catch(IOException ie)
{
ie.printStackTrace();
}
finally
{
try
{
dis.close();
fout.close();
}catch(IOException ie)
{
ie.printStackTrace();
}
}
}
}
0 comments:
Post a Comment