Hello Friends.....this is the code for using FileOutputStream in Java:
Stream.java:
import java.io.*;
class Fileoutput {
 public static void main(String args[])
 {
  String s="This program writes a code into a file name MyFile.txt and store it";
  try
  { 
   OutputStream f1=new FileOutputStream("File1.txt");
   byte b[]=s.getBytes();
   for(int i=0;i<b.length;i++)
   f1.write(b[i]);
   f1.close();
   System.out.println("\nFile1 Written Successfully");
   OutputStream f2=new FileOutputStream("File2.txt");
   f2.write(b);
   f2.close();
   System.out.println("\nFile2 Written Successfully");
  }
  catch(Exception e){}
}
} 
Rock...on........

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.