HdfsUtils { public static List<Path> expandGlobs(List<String> pathsWithGlobs, Configuration conf) throws IOException { List<Path> paths = Lists.newLinkedList(); for (String pathStr : pathsWithGlobs) { Path path = new Path(pathStr); FileSystem fs = path.getFileSystem(conf); FileStatus[] statuses = fs.globStatus(path); if (statuses != null) { for (FileStatus status : statuses) { paths.add(status.getPath()); } } } return paths; } private  HdfsUtils(); static void walkPath(Path path,
                              FileSystem fs,
                              PathFilter filter,
                              PathVisitor visitor); static void collectPaths(Path path,
                                  FileSystem fs,
                                  PathFilter filter,
                                  final List<Path> accumulator); static long getDirectorySize(Path path, FileSystem fs, PathFilter filter); static long getDirectorySize(Path path, FileSystem fs); static List<Path> expandGlobs(List<String> pathsWithGlobs, Configuration conf);  }
@Test public void testExpandGlobs() throws Exception { List<Path> paths = HdfsUtils.expandGlobs( Lists.newArrayList(SAMPLE_DIR_LOCATION + "sample_dir*.txt"), new Configuration()); assertEquals(Lists.newArrayList( "sample_dir/a.txt", "sample_dir/b.txt", "sample_dir/nested/c.txt", "sample_dir/nested/d.txt"), Lists.transform(paths, PATH_TO_RELATIVE_STRING)); }