Package com.norconex.commons.lang
Class ResourceLoader
java.lang.Object
com.norconex.commons.lang.ResourceLoader
Utility class for loading resource from class loader, relative to
a given class.
- Since:
- 1.14.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ReadergetHtmlReader(Class<?> clazz) Gets a UTF-8 reader from resource matching class name with ".html" suffix.static InputStreamgetHtmlStream(Class<?> clazz) Gets a stream from a resource matching class name with ".html" suffix.static StringgetHtmlString(Class<?> clazz) Gets a UTF-8 string from resource matching class name with ".html" suffix.static ReadergetJsonReader(Class<?> clazz) Gets a UTF-8 reader from resource matching class name with ".json" suffix.static InputStreamgetJsonStream(Class<?> clazz) Gets a stream from a resource matching class name with ".json" suffix.static StringgetJsonString(Class<?> clazz) Gets a UTF-8 string from resource matching class name with ".json" suffix.static ReaderGets a UTF-8 resource from class loader as a reader.static InputStreamGets a resource from class loader as stream.static StringGets a UTF-8 a resource from class loader as a string.static ReadergetTxtReader(Class<?> clazz) Gets a UTF-8 reader from resource matching class name with ".txt" suffix.static InputStreamgetTxtStream(Class<?> clazz) Gets a stream from a resource matching class name with ".txt" suffix.static StringgetTxtString(Class<?> clazz) Gets a UTF-8 string from resource matching class name with ".txt" suffix.static ReadergetXmlReader(Class<?> clazz) Gets a UTF-8 reader from resource matching class name with ".xml" suffix.static InputStreamgetXmlStream(Class<?> clazz) Gets a stream from a resource matching class name with ".xml" suffix.static StringgetXmlString(Class<?> clazz) Gets a UTF-8 string from resource matching class name with ".xml" suffix.
-
Field Details
-
TXT
- Since:
- 2.0.0
- See Also:
-
HTML
- Since:
- 2.0.0
- See Also:
-
XML
- Since:
- 2.0.0
- See Also:
-
JSON
- Since:
- 2.0.0
- See Also:
-
-
Method Details
-
getStream
Gets a resource from class loader as stream. The resource is relative to the given class, with the same name as the class, but with the supplied suffix.- Parameters:
clazz- the class to load related resourcesuffix- the suffix of the file to load with the same name as class- Returns:
- input stream or
nullif class isnullor resource could not be found.
-
getReader
Gets a UTF-8 resource from class loader as a reader. The resource is relative to the given class, with the same name as the class, but with the supplied suffix.- Parameters:
clazz- the class to load related resourcesuffix- the suffix of the file to load with the same name as class- Returns:
- reader or
nullif class isnullor resource could not be found.
-
getString
Gets a UTF-8 a resource from class loader as a string. The resource is relative to the given class, with the same name as the class, but with the supplied suffix.- Parameters:
clazz- the class to load related resourcesuffix- the suffix of the file to load with the same name as class- Returns:
- string or
nullif class isnullor resource could not be found.
-
getXmlStream
Gets a stream from a resource matching class name with ".xml" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- XML stream or
null
-
getXmlReader
Gets a UTF-8 reader from resource matching class name with ".xml" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- XML reader or
null
-
getXmlString
Gets a UTF-8 string from resource matching class name with ".xml" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- XML string or
null
-
getTxtStream
Gets a stream from a resource matching class name with ".txt" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- text stream or
null
-
getTxtReader
Gets a UTF-8 reader from resource matching class name with ".txt" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- text reader or
null
-
getTxtString
Gets a UTF-8 string from resource matching class name with ".txt" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- text string or
null
-
getHtmlStream
Gets a stream from a resource matching class name with ".html" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- HTML stream or
null
-
getHtmlReader
Gets a UTF-8 reader from resource matching class name with ".html" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- HTML reader or
null
-
getHtmlString
Gets a UTF-8 string from resource matching class name with ".html" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- HTML string or
null
-
getJsonStream
Gets a stream from a resource matching class name with ".json" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- JSON stream or
null
-
getJsonReader
Gets a UTF-8 reader from resource matching class name with ".json" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- JSON reader or
null
-
getJsonString
Gets a UTF-8 string from resource matching class name with ".json" suffix.- Parameters:
clazz- the class to load related resource- Returns:
- JSON string or
null
-