import java.io.FileOutputStream;
import java.io.IOException;
import java.io.File;
class FileTest
{
public static void main(String Dx[])
{
FileOutputStream fout;
File file;
try{
file=new File("abc.txt");
fout=new FileOutputStream(file);
String s="Hi, Hello ,how r u?";
if(!file.exists())
{file.createNewFile();}
byte[] b=s.getBytes();
fout.write(b);
fout.flush();
fout.close();
System.out.println("Operation is successfully Compleated");
}
catch(Exception e)
{System.out.println(e);}
}
}
import java.io.IOException;
import java.io.File;
class FileTest
{
public static void main(String Dx[])
{
FileOutputStream fout;
File file;
try{
file=new File("abc.txt");
fout=new FileOutputStream(file);
String s="Hi, Hello ,how r u?";
if(!file.exists())
{file.createNewFile();}
byte[] b=s.getBytes();
fout.write(b);
fout.flush();
fout.close();
System.out.println("Operation is successfully Compleated");
}
catch(Exception e)
{System.out.println(e);}
}
}
No comments:
Post a Comment