类 ResourceUtils
java.lang.Object
cn.herodotus.stirrup.core.foundation.utils.ResourceUtils
Description: 资源文件处理工具类
- 作者:
- : gengwei.zheng
- Date:
- : 2021/8/29 21:39
-
方法概要
修饰符和类型方法说明static longcontentLength(String location) static booleanstatic Filestatic StringgetFilename(String location) static InputStreamgetInputStream(String location) static org.springframework.core.io.ResourcegetResource(String location) static org.springframework.core.io.Resource[]getResources(String locationPattern) static URIstatic URLstatic booleanisClasspathAllUrl(String location) static booleanisClasspathUrl(String location) static booleanstatic booleanstatic booleanstatic booleanstatic booleanisReadable(String location) static booleanstatic longlastModified(String location) static StringtoBase64(org.springframework.core.io.Resource resource) 将Resource转换为 Base64 数据。static byte[]toBytes(org.springframework.core.io.Resource resource) 将Resource转换为 byte
-
方法详细资料
-
getResource
-
getFile
- 抛出:
IOException
-
getInputStream
- 抛出:
IOException
-
getFilename
-
getURI
- 抛出:
IOException
-
getURL
- 抛出:
IOException
-
contentLength
- 抛出:
IOException
-
lastModified
- 抛出:
IOException
-
exists
-
isFile
-
isReadable
-
isOpen
-
getResources
public static org.springframework.core.io.Resource[] getResources(String locationPattern) throws IOException - 抛出:
IOException
-
isUrl
-
isClasspathUrl
-
isClasspathAllUrl
-
isJarUrl
-
isFileUrl
-
toBytes
public static byte[] toBytes(org.springframework.core.io.Resource resource) 将Resource转换为 byte- 参数:
resource- 资源Resource- 返回:
- byte 数组
-
toBase64
将Resource转换为 Base64 数据。例如:将图片类型的 Resource 转换为可以直接在前端展现的 Base64 数据
- 参数:
resource- 资源Resource- 返回:
- Base64 类型的字符串
-