Package net.ontopia.utils
Class StreamUtils
java.lang.Object
net.ontopia.utils.StreamUtils
INTERNAL: Utilities for working with streams and readers.
- Since:
- 1.3.3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamgetInputStream(File basedir, String name) INTERNAL: Returns an input stream for the given url.static InputStreamgetInputStream(String name) INTERNAL: Same as getInputStream(null, name);static URLgetResource(String name) INTERNAL: Returns an URL for the given resource name.
-
Field Details
-
CLASSPATH_PREFIX
- See Also:
-
FILE_PREFIX
- See Also:
-
-
Constructor Details
-
StreamUtils
public StreamUtils()
-
-
Method Details
-
getInputStream
INTERNAL: Same as getInputStream(null, name);- Throws:
IOException- Since:
- 3.4.3
-
getInputStream
INTERNAL: Returns an input stream for the given url. Supports file: and classpath:. If no scheme given then file system will be checked before classpath. Exception will be thrown if resource is not found when scheme is given. If no scheme was given null is returned. File references will be interpreted relative to basedir. If basedir is null, it will be ignored.- Throws:
IOException- Since:
- 5.1.1
-
getResource
INTERNAL: Returns an URL for the given resource name. The order of resolving is:- If name starts with 'classpath:' a resource on the classpath will be resolved. If the resource cannot be found, a 'FileNotFoundException' is thrown
- If name starts with 'file:' a resource on the filesystem will be resolved. If the file cannot be found, a 'FileNotFoundException' is thrown
- if name starts with 'jar:' a jar-URL will be created and returned. Only fails if name is not a valid URL
- name is treated as a file system path, if a file exists an URL to it will be returned
- name is treated as a classpath resource, if it is a valid URL and the resource exists, it will be returned.
- null is returned
- Throws:
IOException- Since:
- 3.4.3
-