Package org.eclipse.rdf4j.common.io
Class ResourceUtil
- java.lang.Object
-
- org.eclipse.rdf4j.common.io.ResourceUtil
-
public class ResourceUtil extends java.lang.ObjectResourceUtil is a utility class for retrieving resources (images, property-files, etc) from the classpath.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classResourceUtil.CallerResolverA helper class to get the call context.
-
Constructor Summary
Constructors Constructor Description ResourceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.Class<?>getCaller()Retrieve the calling class of a method in this class.static java.io.InputStreamgetInputStream(java.lang.String resourceName)Get an inputstream on the specified resource.static java.util.PropertiesgetProperties(java.lang.String resourceName)Retrieve a properties resource.static java.lang.StringgetString(java.lang.String resourceName)Retrieve the String contents of the specified resource, obtained by opening in inputstream on the resource and then interpreting the bytes contained in the inputstream as if they represented characters.static java.net.URLgetURL(java.lang.String resourceName)The URL to the specified resource
-
-
-
Method Detail
-
getURL
public static java.net.URL getURL(java.lang.String resourceName)
The URL to the specified resource- Parameters:
resourceName- the name of the resource- Returns:
- the URL to the specified resource, or null if the resource could not be found
-
getInputStream
public static java.io.InputStream getInputStream(java.lang.String resourceName)
Get an inputstream on the specified resource.- Parameters:
resourceName- the name of the resource- Returns:
- an inputstream on the specified resource, or null if the resource could not be found
-
getString
public static java.lang.String getString(java.lang.String resourceName) throws java.io.IOExceptionRetrieve the String contents of the specified resource, obtained by opening in inputstream on the resource and then interpreting the bytes contained in the inputstream as if they represented characters. This may not make sense on all resources. There is no "magic" in this method to read anything other than plain text.- Parameters:
resourceName- the name of the resource- Returns:
- the String contents of the specified resource, or null if the specified resource could not be found
- Throws:
java.io.IOException- when something goes wrong trying to read the resource
-
getProperties
public static java.util.Properties getProperties(java.lang.String resourceName) throws java.io.IOExceptionRetrieve a properties resource.- Parameters:
resourceName- the name of the resource- Returns:
- a Properties object representing the contents of the resource, or null if the specified resource could not be found
- Throws:
java.io.IOException
-
getCaller
private static java.lang.Class<?> getCaller()
Retrieve the calling class of a method in this class.- Returns:
- the calling class of a method in this class, or this class if no other class could be determined.
-
-