File Copy as String


public class FileCopy {
    public static void main(String[] argsthrows FileNotFoundException, IOException {
        FileInputStream fin1=new FileInputStream("D://file1.txt");
        FileInputStream fin2=new FileInputStream("D://file2.txt");
         FileOutputStream fout=new FileOutputStream("D://file2.txt");
        BufferedReader br1=new BufferedReader(new InputStreamReader(fin1));
        BufferedReader br2=new BufferedReader(new InputStreamReader(fin2));
        PrintWriter pr=new PrintWriter(fout);
        String content=br1.readLine();

        System.out.println("Contents of file1.txt are:");
        while(content!=null){
            System.out.println(content);            
             pr.println(content);
            pr.flush();
            content=br1.readLine();
        }
        System.out.println("File copied successfully..!!");
        

        System.out.println("Contents of file2.txt are:");
        String contents=br2.readLine();
        while(contents!=null){
            System.out.println(contents);
            contents=br2.readLine();
        }
    }
}

Output:
Contents of file1.txt are:
hai...
hello.....
how are you....?
File copied successfully..!!
Contents of file2.txt are:
hai...
hello.....
how are you....?