Class ClasspathResourceUtil


  • public class ClasspathResourceUtil
    extends java.lang.Object
    Utility class for dealing with classpath resources.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String classpathResourceToString​(java.lang.String resource, java.nio.charset.Charset charset)
      Retrieves a classpath resource using the ClasspathResourceUtil classloader and converts it to a String using the specified character set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClasspathResourceUtil

        public ClasspathResourceUtil()
    • Method Detail

      • classpathResourceToString

        public static java.lang.String classpathResourceToString​(java.lang.String resource,
                                                                 java.nio.charset.Charset charset)
                                                          throws UncheckedIOException
        Retrieves a classpath resource using the ClasspathResourceUtil classloader and converts it to a String using the specified character set. If any error occurs while reading the resource, this method throws UncheckedIOException. If the classpath resource cannot be found, this method throws a FileNotFoundException wrapped in an UncheckedIOException.
        Parameters:
        resource - classpath resource to load
        charset - charset to use to decode the classpath resource
        Returns:
        a String
        Throws:
        UncheckedIOException - if the classpath resource cannot be found or cannot be read for any reason