CopyFile.copy(filePath+"记录报表/", "/storage/usbdisk/冲动测试导出表目录/");
public static boolean copy(String src, String des) {
File file1=new File(src);
File[] fs=file1.listFiles();
File file2=new File(des);
if(!file2.exists()){
file2.mkdirs();
}
for (File f : fs) {
if(f.isFile()){
boolean b= fileCopy(f.getPath(),des+"\\"+f.getName()); //调用文件拷贝的方法
if (!b) {
return b;
}
}
// else if(f.isDirectory()){
// copy(f.getPath(),des+"\\"+f.getName());
// }
}
return true;
}
/**
* 文件拷贝的方法
*/
public static boolean fileCopy(String src, String des) {
BufferedReader br=null;
PrintStream ps=null;
try {
br=new BufferedReader(new InputStreamReader(new FileInputStream(src)));
ps=new PrintStream(new FileOutputStream(des));
String s=null;
while((s=br.readLine())!=null){
ps.println(s);
ps.flush();
}
return true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
return false;
} catch (IOException e) {
// TODO Auto-generated catch block
return false;
}finally{
try {
if(br!=null) br.close();
if(ps!=null) ps.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}