@@ -0,0 +1,2563 @@
+package com.tvd12.ezyfox.util;%0A%0Aimport java.io.File;%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;%0Aimport java.util.Set;%0Aimport java.util.function.Predicate;%0A%0Aimport com.google.common.collect.Sets;%0A%0Apublic final class EzyFileUtil %7B%0A%0A%09private static final int NOT_FOUND = -1;%0A%09private static final String EMPTY_STRING = %22%22;%0A%09public static final char EXTENSION_SEPARATOR = '.';%0A%09private static final Predicate%3CFile%3E EMPTY_FILTER = t -%3E true;%0A%09%0A%09private EzyFileUtil() %7B%0A%09%7D%0A%09%0A%09public static Collection%3CFile%3E listFiles(File directory, boolean recursive) %7B%0A        return listFiles(directory, EMPTY_FILTER, recursive);%0A    %7D%0A%09%0A%09public static Collection%3CFile%3E listFiles(%0A%09%09%09File directory, %0A%09%09%09String%5B%5D extensions, boolean recursive) %7B%0A        return listFiles(directory, Sets.newHashSet(extensions), recursive);%0A    %7D%0A%09%0A%09public static Collection%3CFile%3E listFiles(%0A%09%09%09File directory, %0A%09%09%09Set%3CString%3E extensions, boolean recursive) %7B%0A        ExtensionsFilter filter = new ExtensionsFilter(extensions);%0A        return listFiles(directory, filter, recursive);%0A    %7D%0A%09%0A%09public static Collection%3CFile%3E listFiles(%0A%09%09%09File directory, %0A%09%09%09Predicate%3CFile%3E filter, boolean recursive) %7B%0A        List%3CFile%3E files = new ArrayList%3C%3E();%0A        listFiles0(directory, filter, recursive, files);%0A        return files;%0A    %7D%0A%09%0A%09private static void listFiles0(%0A%09%09%09File directory, %0A%09%09%09Predicate%3CFile%3E filter, %0A%09%09%09boolean recursive, Collection%3CFile%3E output) %7B%0A        File%5B%5D files = directory.listFiles();%0A        for(File file : files) %7B%0A        %09%09if(file.isDirectory())%0A        %09%09%09continue;%0A        %09%09if(filter.test(file))%0A        %09%09%09output.add(file);%0A        %7D%0A        if(recursive) %7B%0A        %09%09for(File file : files) %7B%0A        %09%09%09if(file.isDirectory())%0A        %09%09%09%09listFiles0(file, filter, recursive, output);%0A        %09%09%7D%0A        %7D%0A    %7D%0A%09%0A%09public static String getFileExtension(String fileName) %7B%0A        int index = fileName.lastIndexOf(EXTENSION_SEPARATOR);%0A        if (index == NOT_FOUND)%0A            return EMPTY_STRING;%0A        String answer = fileName.substring(index + 1);%0A        return answer;%0A    %7D%0A%09%0A%09private static class ExtensionsFilter implements Predicate%3CFile%3E %7B%0A%09%09private final Set%3CString%3E extensions;%0A%09%09%0A%09%09public ExtensionsFilter(Set%3CString%3E extensions) %7B%0A%09%09%09this.extensions = extensions;%0A%09%09%7D%0A%09%09%0A%09%09@Override%0A%09%09public boolean test(File file) %7B%0A%09%09%09String fileName = file.getName();%0A%09    %09%09String fileExtension = getFileExtension(fileName);%0A%09    %09%09if(extensions.contains(fileExtension))%0A%09    %09%09%09return true;%0A%09    %09%09return false;%0A%09%09%7D%0A%09%7D%0A%7D%0A

add file util