获取目录下所有文件名称(带路径)

public static void getFolderAllFiles(File dir, List filenameList)
    {
        if (dir.isDirectory() && dir.canRead() && dir.canWrite())
        {
            File[] allfiles = dir.listFiles( new FileFilter()
            {
                public boolean accept(File pathname)
                {
                    if (pathname.canRead() )
                        return true;
                    else
                        return false;
                }
            });

            for(File file : allfiles)
            {
                if ( file.isFile() ) {
                    filenameList.add(file.getPath());
                } else {
                    getFolderAllFiles(file, filenameList);
                }
            }
        }
    }

你可能感兴趣的:(Util)