Class ResourceUtil
java.lang.Object
org.apache.sling.testing.clients.util.ResourceUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStream
getResourceAsStream
(String resourcePath) We must get the Resource as a stream from the ContextClassLoader and not from the normal classLoader acquired by using getClass.getClassLoader, since we must be able to load resources from different threads e.g.static String
readResourceAsString
(String resource) Helper method to read a resource from class usingClass.getResourceAsStream(String)
and convert into a String.
-
Constructor Details
-
ResourceUtil
public ResourceUtil()
-
-
Method Details
-
getResourceAsStream
We must get the Resource as a stream from the ContextClassLoader and not from the normal classLoader acquired by using getClass.getClassLoader, since we must be able to load resources from different threads e.g. running in ant.- Parameters:
resourcePath
- path to the resource- Returns:
- resource as InputStream
-
readResourceAsString
Helper method to read a resource from class usingClass.getResourceAsStream(String)
and convert into a String.- Parameters:
resource
- The resource to read.- Returns:
- The requested resource as String, resolved using
Class.getResourceAsStream(String)
, ornull
if the requested resource cannot be resolved for some reason - Throws:
IOException
- if the Resource Stream cannot be read
-