Copying charecter from one File to another File

import java.io.*;
public class FileChar {
    public static void main(String args[]) throws IOException
    {
        File f=new File(args[0]);
        int n;
        char a[]=new char[50];
        String str;
       
        if(args.length!=2)
        {
            System.out.print("File Not Entered..");
            System.exit(0);
        }
        if(f.exists())
        {
            FileReader fr=new FileReader(f);
            System.out.println("Reading :"+args[0]);
            fr.read(a);
            for(char c : a)
            {
                System.out.print(c);
            }
            System.out.println();
        }
        else
        {
            System.out.println("File does Not Exist :"+args[0]);
            System.exit(0);
        }
       
        String s=new String(a);
        System.out.println("Writing :"+args[1]);
        FileWriter fw=new FileWriter(args[1]);
        fw.write(s);
        fw.close();
        System.out.print("Content Copied..");
    }
}


No comments: