文章标题
来源:互联网 发布:数据港 编辑:程序博客网 时间:2024/06/11 21:19
复制目录文件函数
public static boolean copyFolder(File srcFile, File destFile) { if (!srcFile.isDirectory()) { return false; } if (!destFile.exists() && !destFile.mkdirs()) { return false; } boolean result = true; File[] list = srcFile.listFiles(); if (list == null) { return result; } for (File f:list) { if (f.isDirectory()) { result &= copyFolder (f,new File(destFile,f.getName())); } else { result &= copyFile(f,new File(destFile,f.getName())); } } return result; }
public static boolean copyFile(File srcFile, File destFile) { boolean result = false; try { InputStream in = new FileInputStream(srcFile); try { result = copyToFile(in, destFile); } finally { in.close(); } } catch (IOException e) { result = false; } return result; }
public static boolean copyToFile(InputStream inputStream, File destFile) { try { if (destFile.exists()) { destFile.delete(); } FileOutputStream out = new FileOutputStream(destFile); try { byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = inputStream.read(buffer)) >= 0) { out.write(buffer, 0, bytesRead); } } finally { out.flush(); try { out.getFD().sync(); } catch (IOException e) { } out.close(); } return true; } catch (IOException e) { return false; } }
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- iOS开发之<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0”/>
- 树形结构的数据库表Schema设计
- 解决maven项目自动修改jdk版本问题
- 图像识别常用的数据库
- 只在某页面屏幕旋转,其他竖屏
- 文章标题
- Java 线程 synchronized 学习
- AES 代码实现
- UE4 三维点击事件
- 程序员提升效率的工具
- Swift 数值运算符
- VS2015使用小技巧 同时调试两个控制台程序
- cm12 for 三星n7100编译
- HTML表格导出到EXCEL