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);
}

 

posted on 2015-08-11 12:54  agilezing  阅读(3716)  评论(0编辑  收藏  举报

导航