Class Resources

java.lang.Object
cn.xuanyuanli.core.util.Resources

public class Resources extends Object
资源工具
Author:
John Li
  • Field Details

    • logger

      private static final org.slf4j.Logger logger
      日志记录器
    • DEFAULT_RESOURCE_PATTERN

      static final String DEFAULT_RESOURCE_PATTERN
      默认资源模式
      See Also:
    • RESOURCE_PATTERN_RESOLVER

      private static final org.springframework.core.io.support.ResourcePatternResolver RESOURCE_PATTERN_RESOLVER
      资源模式解析器
  • Constructor Details

    • Resources

      public Resources()
  • Method Details

    • getPackageClasses

      public static List<Class<?>> getPackageClasses(String packageName)
      获得包下的所有class
      Parameters:
      packageName - 包名
      Returns:
      Listinvalid input: '<'Classinvalid input: '<'
      invalid @link
      {@link ?
      }>>
    • getRealPackageName

      private static String getRealPackageName(String filePath, String packageName)
      获得真实的文件系统的包路径
      Parameters:
      filePath - 文件路径
      packageName - 包名
      Returns:
      String
    • getProperties

      public static Properties getProperties(String fileName)
      获取所有classpath下对应名称的Properties文件属性
      Parameters:
      fileName - 相对于classpath的文件位置
      Returns:
      Properties
    • getCurrentClasspathProperties

      public static Properties getCurrentClasspathProperties(String fileName)
      获取当前classpath下对应名称的Properties文件属性
      Parameters:
      fileName - 相对于classpath的文件位置
      Returns:
      Properties
    • getClassPathAllResources

      public static org.springframework.core.io.Resource[] getClassPathAllResources(String resourceName)
      获得classpath*下的指定资源
      Parameters:
      resourceName - 资源名称
      Returns:
      Resource
    • getClassPathResources

      public static org.springframework.core.io.Resource getClassPathResources(String resourceName)
      获得classpath下的指定资源
      Parameters:
      resourceName - 资源名称
      Returns:
      Resource
    • getCurrentClasspath

      public static File getCurrentClasspath()
      获得当前的classpath目录
      Returns:
      File
    • getProjectPath

      public static String getProjectPath()
      获得当前项目路径(只限于Eclipse或IDEA中管用)
      Returns:
      String
    • getJarHome

      public static String getJarHome(Class<?> cl)
      获得某个class所在的jar所在的目录(例如打包A项目为jar,获取的就是A.jar所在的目录)
      Parameters:
      cl - cl
      Returns:
      String
    • isJarFile

      public static boolean isJarFile(URL url)
      文件是否来自于Jar中
      Parameters:
      url - url
      Returns:
      boolean
    • isJarStartByClass

      public static boolean isJarStartByClass(Class<?> cl)
      此Class是否从jar中启动
      Parameters:
      cl - cl
      Returns:
      boolean
    • getClassPathResourcesInputStream

      public static InputStream getClassPathResourcesInputStream(String path)
      获得classpath下的指定资源--InputStream
      Parameters:
      path - 路径
      Returns:
      InputStream