public class ResourceUtil extends Object
Constructor and Description |
---|
ResourceUtil() |
Modifier and Type | Method and Description |
---|---|
static 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 using
Class.getResourceAsStream(String)
and convert into a String. |
public static InputStream getResourceAsStream(String resourcePath)
resourcePath
- path to the resourcepublic static String readResourceAsString(String resource) throws IOException
Class.getResourceAsStream(String)
and convert into a String.resource
- The resource to read.Class.getResourceAsStream(String)
, or null
if the requested resource cannot be resolved for some reasonIOException
- if the Resource Stream cannot be readCopyright © 2007–2018 The Apache Software Foundation. All rights reserved.