public void copyFile(String oldPath, String newPath) throws IOException {
(new File(newPath)).mkdirs();
String[] file = new File(oldPath).list();
File fileTemp = null;
String separator = File.separator;
for (int i = 0; i < file.length; i++) {
if (oldPath.endsWith(separator)) {
fileTemp = new File(oldPath + file[i]);
} else {
fileTemp = new File(oldPath + separator + file[i]);
}
if (fileTemp.isFile()) {
FileInputStream fis = new FileInputStream(fileTemp);
if (file[i].endsWith(".txt")) {
fileTemp = new File(oldPath + separator + file[i].substring(0, file[i].length() - 4) + ".sql");
}
FileOutputStream fos = new FileOutputStream(newPath + "/" + fileTemp.getName());
byte[] b = new byte[1024 * 5];
int len;
while ((len = fis.read(b)) != -1) {
fos.write(b, 0, len);
}
fos.flush();
fos.close();
fis.close();
}
if (fileTemp.isDirectory()) {
this.copyFile(oldPath + "/" + file[i], newPath + "/" + file[i]);
}
}
}

  

最新文章

  1. My year of 2016
  2. springboot+dubbo
  3. 按钮点击,打开qq,用做联系客服
  4. php 升级到 5.3+ 后出现的一些错误,如 ereg(); ereg_replace(); 函数报错
  5. Extjs TabPanel 选项卡延迟加载
  6. Installing MySQL Server on CentOS
  7. Hibernate缓存之初探
  8. Form_Form Builder国际化多语言开发(案例)
  9. 在Windows下Mysql如何重置root用户密码
  10. z-index无效
  11. iOS开发那些事--性能优化–内存泄露问题的解决(转)
  12. dagger和butterknife使用冲突
  13. 【解决】Microsoft Visual Studio 2012 打开2008下编译的silverlight3项目
  14. 使用socket.io打造公共聊天室
  15. 数据挖掘相关的10个问题[ZZ]
  16. vue实现仿淘宝结账页面
  17. Python函数篇:装饰器
  18. HTTP常用方法
  19. nginx.conf添加lua.conf配置
  20. Win7环境 搭建IIS环境。发布asp.net MVC项目到IIS(第一期)

热门文章

  1. O058、Snapshot Volume 操作
  2. mybatis-plus使用Oracle函数生成主键
  3. C# 移除数组中重复项
  4. vue-app物理返回键跳到指定页面
  5. MySQL 5.7.18 zip版本的安装使用方法
  6. 【转】FireMonkey ListView 自动计算行高
  7. solr7中文分词包
  8. 基于UDS的BootLoader
  9. c++ 常用数据类型转换
  10. Linux下计划任务:crontab 命令的权限说明