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

com.lx.util.LXFileUtil Maven / Gradle / Ivy

Go to download

使用文档: https://a7fi97h1rc.feishu.cn/docx/X3LRdtLhkoXQ8hxgXDQc2CLOnEg?from=from_copylink

There is a newer version: 1.1
Show newest version
package com.lx.util;

import com.lx.annotation.Note;

import java.io.File;
import java.io.InputStream;

class LXFileUtil {

    @Note("获取类路径下的文件路径")
    public static String getClassPath(Class cls, String path){
        return cls.getResource("").getPath()+getPath(path);
    }

    @Note("获取resource路径下的文件路径")
    public static String getResourcePath(String path){
        return ClassLoader.getSystemResource("").getPath()+getPath(path);
    }
    @Note("获取文件输入流")
    public static InputStream getFileInputstream(String path){
        return ClassLoader.getSystemResourceAsStream(getPath(path));
    }
    //说明: 获取文件路径
    /** @author ylx 2022/12/23 9:50 */
    public static String getPath(String path){
        if (LX.isEmpty(path)) {
            return "";
        }
        return path.replaceAll("\\+", File.separator).replaceAll("/+", File.separator);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy