Develop a Java program to transfer the contents of one file to another using BufferedReader

import java.io.*;

public class Exp11_2
{
 public static void main(String[] args) throws IOException 
 {
  FileInputStream fis = new FileInputStream("sample.txt");
  BufferedReader in = new BufferedReader(new InputStreamReader(fis));
  FileWriter fstream = new FileWriter("dest.txt", true);
  BufferedWriter out = new BufferedWriter(fstream);
  String aLine = null;
  while ((aLine = in.readLine()) != null) 
  {
   out.write(aLine);
   out.newLine();
  }

  in.close();
  out.close();
 }
}
/*  OUTPUT!!!
To get the output please keep "sample.txt" file with the program.
It will automatically copy the contents of that file into "dest.txt"
*/


Java Programs
Copyright © LetML. Blogger Templates Designed by OddThemes