//COPY 文件及文件夹,整个一下子读取,不用while---对小文件试用,内存缓冲压力较小
private void copy(String srcpath,String decpath) throws Exception {
File file = new File(srcpath);
File file2 = new File(decpath);
if(file.isFile()){
FileInputStream fis = new FileInputStream(file);
FileOutputStream fot = new FileOutputStream(file2);
byte[] by = new byte[(int)file.length()];
int a = 0;
//while( (a = fis.read(by)) != -1){
// fot.write(by, 0, a);
//注意不能 fot.write(by) 会造成新文件比老文件大,不是每个都正好by大小
//}
fis.read(by);
fot.write(by);
fis.close();
fot.flush();
fot.close();
}else if(file.isDirectory()){
file2.mkdirs();
String[] files = file.list();
for(int i = 0 ;i < files.length ; i++){
copy(srcpath+"\\"+files[i],decpath+"\\"+files[i]);
}
}
}