import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; class CopyFileContentsInOtherFile { public static void main(String[] args) { try { File f1=new File(args[0]); File f2=new File(args[1]); if(f1.exists()==false) { System.out.println("Can't Copy Source File Not Exists"); System.exit(0); } if(f2.exists()==true) { System.out.println("Can't Copy Destination File Exists"); System.exit(0); } FileInputStream fis=new FileInputStream(f1); FileOutputStream fos=new FileOutputStream(f2); int x; while((x=fis.read())!=-1) { fos.write(x); } System.out.println("Contents of file '"+f1+"' are copied in '"+f2+"' successful..."); fis.close(); fos.close(); } catch(Exception ee) { System.out.println(ee); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)