@@ -0,0 +1,2282 @@
+package dbtools.common.file;%0A%0Aimport dbtools.common.utils.StrUtils;%0A%0Aimport java.io.File;%0Aimport java.io.FilenameFilter;%0A%0Apublic class FileUtils %7B%0A    public static String getOutputFileName(File parent, File file, String fileExt, String fileName, String folderName) %7B%0A        if (file == null %7C%7C parent == null) %7B%0A            return null;%0A        %7D%0A%0A        String outputFileName = null;%0A        if (parent.isDirectory()) %7B%0A            // Prepare the folder firstly%0A            String outputFolderName = String.format(%22%25s%25s%22, parent.getPath(), folderName);%0A            File folder = new File(outputFolderName);%0A            if (!folder.exists()) %7B%0A                folder.mkdir();%0A            %7D%0A%0A            // Output file name%0A            outputFileName = String.format(%22%25s%5C%5C%25s%22, outputFolderName, file.getName());%0A        %7D else %7B%0A            outputFileName = file.getPath();%0A        %7D%0A%0A        // Format the file name%0A        if (!StrUtils.isEmpty(outputFileName)) %7B%0A            if (outputFileName.toLowerCase().endsWith(fileExt)) %7B%0A                outputFileName = outputFileName.substring(0, outputFileName.length() - fileExt.length());%0A            %7D%0A            outputFileName = String.format(%22%25s%25s%22, outputFileName, fileName);%0A        %7D%0A%0A        return outputFileName;%0A    %7D%0A%0A    public static File%5B%5D findFiles(String filePath, final String fileExt, final String ignoreFileName) %7B%0A        if (StrUtils.isEmpty(filePath)) %7B%0A            return null;%0A        %7D%0A%0A        File file = new File(filePath);%0A        if (!file.exists()) %7B%0A            return null;%0A        %7D%0A%0A        // File or directory, while not iterate sub folders%0A        File%5B%5D files = null;%0A        if (file.isFile() && filePath.toLowerCase().endsWith(fileExt)) %7B%0A            files = new File%5B%5D%7Bfile%7D;%0A        %7D else if (file.isDirectory()) %7B%0A            files = file.listFiles(new FilenameFilter() %7B%0A                // @Override%0A                public boolean accept(File dir, String name) %7B%0A                    if (StrUtils.isEmpty(name)) %7B%0A                        return false;%0A                    %7D%0A                    String str = name.toLowerCase();%0A                    return str.endsWith(fileExt) && !str.endsWith(ignoreFileName);%0A                %7D%0A            %7D);%0A        %7D%0A%0A        return files;%0A    %7D%0A%7D%0A

Refactor the code for findFiles and getOutputFileName