编辑代码


public class Test {
public static void copy(File source,File target){
InputStream in=null;

OutputStream out=null;

try {

in=new BufferedInputStream(new FileInputStream(source));

out=new BufferedOutputStream(new FileOutputStream(target));

byte[] buff=new byte[1024];

while(in.read(buff)>0){

out.write(buff);

}

} catch (Exception e) {


e.printStackTrace();

}finally{

try {

if(in!=null)

in.close();

if(out!=null)

out.close();

} catch (Exception e2) {


}

}

}

public static void main(String[] args) {


}
}