类 ResourceUtils

java.lang.Object
cn.herodotus.stirrup.core.foundation.utils.ResourceUtils

public class ResourceUtils extends Object

Description: 资源文件处理工具类

作者:
: gengwei.zheng
Date:
: 2021/8/29 21:39
  • 方法详细资料

    • getResource

      public static org.springframework.core.io.Resource getResource(String location)
    • getFile

      public static File getFile(String location) throws IOException
      抛出:
      IOException
    • getInputStream

      public static InputStream getInputStream(String location) throws IOException
      抛出:
      IOException
    • getFilename

      public static String getFilename(String location)
    • getURI

      public static URI getURI(String location) throws IOException
      抛出:
      IOException
    • getURL

      public static URL getURL(String location) throws IOException
      抛出:
      IOException
    • contentLength

      public static long contentLength(String location) throws IOException
      抛出:
      IOException
    • lastModified

      public static long lastModified(String location) throws IOException
      抛出:
      IOException
    • exists

      public static boolean exists(String location)
    • isFile

      public static boolean isFile(String location)
    • isReadable

      public static boolean isReadable(String location)
    • isOpen

      public static boolean isOpen(String location)
    • getResources

      public static org.springframework.core.io.Resource[] getResources(String locationPattern) throws IOException
      抛出:
      IOException
    • isUrl

      public static boolean isUrl(String location)
    • isClasspathUrl

      public static boolean isClasspathUrl(String location)
    • isClasspathAllUrl

      public static boolean isClasspathAllUrl(String location)
    • isJarUrl

      public static boolean isJarUrl(URL url)
    • isFileUrl

      public static boolean isFileUrl(URL url)
    • toBytes

      public static byte[] toBytes(org.springframework.core.io.Resource resource)
      Resource 转换为 byte
      参数:
      resource - 资源 Resource
      返回:
      byte 数组
    • toBase64

      public static String toBase64(org.springframework.core.io.Resource resource)
      Resource 转换为 Base64 数据。

      例如:将图片类型的 Resource 转换为可以直接在前端展现的 Base64 数据

      参数:
      resource - 资源 Resource
      返回:
      Base64 类型的字符串