com.lx.util.LXFileUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lxboot3 Show documentation
Show all versions of lxboot3 Show documentation
使用文档: https://a7fi97h1rc.feishu.cn/docx/X3LRdtLhkoXQ8hxgXDQc2CLOnEg?from=from_copylink
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