Class ResourceHelper


  • public class ResourceHelper
    extends Object
    Helper for acquiring resources
    • Constructor Detail

      • ResourceHelper

        public ResourceHelper()
    • Method Detail

      • getFullName

        public static String getFullName​(String parent,
                                         String resource)
        Returns the full path name for this resource, handling nulls
      • getName

        public static String getName​(String resource)
        Returns the unqualified resource name
      • getParentName

        public static String getParentName​(String resource)
        Returns the name of the parent resource, or empty string if no separator is found on the resource name
      • getResource

        public static URL getResource​(String resource)
        Returns a resource using the current thread's class loader
      • getSize

        public static long getSize​(String resource)
        Returns the resource size, handling files and jar file entries
      • listResources

        public static List<String> listResources​(String path)
        Returns a list of resources according to the class path or file resources, optionally recursive
      • readBytes

        public static byte[] readBytes​(String resource)
                                throws IOException
        Reads the content of the given resource, returning the bytes, or null if not found
        Throws:
        IOException
      • readContent

        public static String readContent​(String resource)
                                  throws IOException
        Reads the content of the given resource, returning the string, or null if not found
        Throws:
        IOException