All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pro.shuangxi.utils.FileUtils Maven / Gradle / Ivy

package pro.shuangxi.utils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author mengshx
 * 文件相关工具类
 * datetime 2022-07-15 11:00
 **/
public class FileUtils {
    public static List getFileRelativePath(File directory, String suffix) {
        List pathList = new ArrayList<>();
        getPath(pathList, "", directory,suffix);
        return pathList;
    }

    private static void getPath(List pathList, String path, File directory,String suffix) {
        for (File file : directory.listFiles()) {
            if (file.isDirectory()) {
                getPath(pathList,path+file.getName()+File.separator,file,suffix);
            }else {
                if (file.getName().contains(suffix)) {
                    pathList.add(path + file.getName());
                }
            }
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy