public int copyFile(String src, String dst) {
try {
int len = 0;
byte[] buf = new byte[1024];
FileInputStream fis = new FileInputStream(src);
FileOutputStream fos = new FileOutputStream(dst);
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fis.close();
fos.close();
} catch (IOException e) {
System.out.println(e);
return -1;
}
return 0;
}
public boolean copyAllFile(String srcPath, String dstPath){
try {
File path = new File(srcPath);// 查询路径
String[] strList;// 存放所有查询结果
int i = 0;
strList = path.list();// 执行查询
for (i = 0; i < strList.length; i++) {
String srcFilePath = srcPath + "/" + strList[i];// 确定真实路径
String toFilePath = dstPath + "/" + strList[i];// 确定真实路径
copyFile(srcFilePath,toFilePath);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}