Class IOUtil


  • public class IOUtil
    extends Object
    • Constructor Detail

      • IOUtil

        public IOUtil()
    • Method Detail

      • getStreamFromResource

        public static InputStream getStreamFromResource​(Class<?> clazz,
                                                        String resourceName)
                                                 throws IOException
        Get a string from a Resource . This can either be a URL, an absolute file name or a relative file name. A special URL that has a scheme of res is also supported, this gets the resource by name from the classloader that provided clazz.
        Parameters:
        clazz - class to get classloader from (null to skip loading as classpath resource)
        resourceName - resource name
        Returns:
        resource stream
        Throws:
        IOException
        IOException - on any error loading
      • getStringFromResource

        public static String getStringFromResource​(Class<?> clazz,
                                                   String resourceName)
                                            throws IOException
        Get a string from a Resource . This can either be a URL, an absolute file name or a relative file name. A special URL that has a scheme of res is also supported, this gets the resource by name from the classloader that provided clazz.
        Parameters:
        clazz - class to get classloader from (null to skip loading as classpath resource)
        resourceName - resource name
        Returns:
        content of resource
        Throws:
        IOException
        IOException - on any error loading
      • getStringFromResource

        public static String getStringFromResource​(Class<?> clazz,
                                                   String resourceName,
                                                   String charset)
                                            throws IOException
        Get a string from a Resource . This can either be a URL, an absolute file name or a relative file name. A special URL that has a scheme of res is also supported, this gets the resource by name from the classloader that provided clazz.
        Parameters:
        clazz - class to get classloader from (null to skip loading as classpath resource)
        resourceName - resource name
        charset - character set
        Returns:
        content of resource
        Throws:
        IOException
        IOException - on any error loading