public class ResourceUtils extends Object
Constructor and Description |
---|
ResourceUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
forName(Class<?> classType,
String className,
String[] options)
Creates a new instance of an object given it's class name and (optional)
arguments to pass to it's setOptions method.
|
static File |
getWekaHome()
Returns the Weka home directory.
|
static Properties |
readProperties(String resourceName)
Reads properties that inherit from three locations.
|
static Properties |
readProperties(String resourceName,
ClassLoader loader)
Reads properties that inherit from three locations.
|
public static Object forName(Class<?> classType, String className, String[] options) throws Exception
String classifierName = Utils.getOption('W', options);
Classifier c = (Classifier)Utils.forName(Classifier.class,
classifierName,
options);
setClassifier(c);
classType
- the class that the instantiated object should be
assignable to -- an exception is thrown if this is not the caseclassName
- the fully qualified class name of the objectoptions
- an array of options suitable for passing to setOptions. May
be null. Any options accepted by the object will be removed from
the array.Exception
- if the class name is invalid, or if the class is not
assignable to the desired class type, or the options supplied
are not acceptable to the objectpublic static Properties readProperties(String resourceName) throws Exception
resourceName
- the location of the resource that should be loaded.
e.g.: "weka/core/Utils.props". (The use of hardcoded forward
slashes here is OK - see jdk1.1/docs/guide/misc/resources.html)
This routine will also look for the file (in this case)
"Utils.props" in the users home directory and the current
directory.Exception
- if no default properties are defined, or if an error
occurs reading the properties files.public static Properties readProperties(String resourceName, ClassLoader loader) throws Exception
resourceName
- the location of the resource that should be loaded.
e.g.: "weka/core/Utils.props". (The use of hardcoded forward
slashes here is OK - see jdk1.1/docs/guide/misc/resources.html)
This routine will also look for the file (in this case)
"Utils.props" in the users home directory and the current
directory.loader
- the class loader to use when loading propertiesException
- if no default properties are defined, or if an error
occurs reading the properties files.public static File getWekaHome()
Copyright © 2019 University of Waikato, Hamilton, NZ. All rights reserved.