public static void deletePathByRegex ( FileSystem fs , final Path path , final String regex ) throws IOException { FileStatus [ ] statusList = fs . listStatus ( path , path1 -> path1 . getName ( ) . matches ( regex ) ) ; for ( final FileStatus oldJobFile : statusList ) { HadoopUtils . deletePath ( fs , oldJobFile . getPath ( ) , true ) ; } }
Delete files according to the regular expression provided