- java.lang.Object
-
- org.tentackle.common.FileHelper
-
public class FileHelper extends java.lang.ObjectHelper methods for file handling.- Author:
- harald
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.InputStreamcreateInputStream(java.lang.Class<?> caller, java.lang.String name)Creates an input stream from a resource.static java.util.PropertiesloadProperties(java.lang.String name)Loads properties.
Tries to load from filesystem first, then from classpath.static java.util.PropertiesloadProperties(java.lang.String name, boolean asResource)Loads properties from a resource.
-
-
-
Method Detail
-
createInputStream
public static java.io.InputStream createInputStream(java.lang.Class<?> caller, java.lang.String name) throws java.io.IOExceptionCreates an input stream from a resource.- Parameters:
caller- the caller class, null to determine via Stackwalkername- the resource name- Returns:
- the input stream
- Throws:
java.io.IOException- if reading the resources failedjava.io.FileNotFoundException- if no such resources found
-
loadProperties
public static java.util.Properties loadProperties(java.lang.String name, boolean asResource) throws java.io.IOExceptionLoads properties from a resource.- Parameters:
name- the properties name, null if return empty propertiesasResource- true if load from the classpath, false if from filesystem- Returns:
- the properties, empty if filename is null
- Throws:
java.io.IOException- if reading the property file failedjava.io.FileNotFoundException- if no properties found
-
loadProperties
public static java.util.Properties loadProperties(java.lang.String name) throws java.io.IOExceptionLoads properties.
Tries to load from filesystem first, then from classpath.- Parameters:
name- the properties name, null if return empty properties- Returns:
- the properties, empty if filename is null
- Throws:
java.io.IOException- if reading the property file failedjava.io.FileNotFoundException- if no properties found
-
-