import java.io.*;
public class Test{
public static void main(String[] args)
{
if(args.length<3)
{
System.out.println(args.length);
return;
}
else{
java.io.File f1=new File(args[0]);
java.io.File f2=new File(args[1]);
java.io.File path=new File(args[2]);
String newname;
if(f1.isFile()&&f2.isFile()&&path.isDirectory())
{
try{
String fn1=f1.getName();
fn1=fn1.substring(0,fn1.lastIndexOf("."));
String fn=f2.getName();
newname=fn1+fn.substring(fn.lastIndexOf("."),fn.length());
newname=path.getCanonicalPath()+newname;
File f3=new File(newname);
if(!f3.exists())
f3.createNewFile();
java.io.DataInputStream ids=new java.io.DataInputStream(new FileInputStream(f2));
java.io.DataOutputStream ods=new java.io.DataOutputStream(new FileOutputStream(f3));
byte[] bt=new byte[4096];
while(ids.available()>0){
ids.read(bt);
ods.write(bt);
}
ids.close();
ods.close();
}catch(Exception e){
e.printStackTrace();
return;
}
System.out.println("file "+f2.getAbsolutePath()+" successfully copied to "+newname);
}
}
}
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。