Configuration conf = new Configuration();
FileSystem hdfs = FileSystem.get(URI.create(args[1]),conf);
FileStatus[] listStatus = hdfs.listStatus(new Path(args[1]));
Path[] listPath = FileUtil.stat2Paths(listStatus);
for(Path p : listPath){
String fileNamePath = p.toString();//获得带路径的文件名字符串
String fileName = p.getName();//获取文件名
String regex = "keyword+//-[0-9]+//-r+//-00000";//keyword-00-r-00000
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(fileName);
if(matcher.matches()){
//找到满足的文件,做下一步处理
}
hdfs获取文件列表,利用正则表达式选择文件并作下一步处理
最新推荐文章于 2022-09-15 17:12:03 发布