hadoop 文件 复制 移动 FileUtil.copy


FileSystem fs = FileSystem.get(conf);
Path pattern = new Path(resultViewPath + "phone*");
Path dir = new Path(dest);
if (!fs.exists(dir)) {      // 目标目录
fs.mkdirs(dir);
}
FileStatus[] status = fs.globStatus(pattern);   //  匹配正则表达式的文件集合
Path[] paths = FileUtil.stat2Paths(status);      //  转换为Path数组
for (Path i : paths) {                                  //   复制每个文件
FileUtil.copy(fs, i, fs, dir, false, conf);   // false 表示移动的时候不删除原路径文件
System.out.println(i);
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM