|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.fuin.utils4j.Utils4J
public final class Utils4J
Common utility methods for use in Java applications and libraries.
| Method Summary | |
|---|---|
static void |
addToClasspath(java.lang.String url)
Adds an URL to the classpath. |
static void |
addToClasspath(java.net.URL url)
Adds an URL to the classpath. |
static void |
checkValidDir(java.io.File dir)
Check if the argument is an existing directory. |
static void |
checkValidFile(java.io.File file)
Check if the argument is an existing file. |
static boolean |
containsURL(java.net.URL[] urls,
java.net.URL url)
Checks if the array or URLs contains the given URL. |
static java.lang.String |
createHash(java.io.File file)
Creates an MD5 hash from a file. |
static java.lang.Object |
createInstance(java.lang.String className)
Create an instance with Class.forName(..) and wrap all exceptions into RuntimeExceptions. |
static java.net.URL |
createUrl(java.net.URL baseUrl,
java.lang.String path,
java.lang.String filename)
Creates an URL based on a directory a relative path and a filename. |
static java.lang.String |
getPackagePath(java.lang.Class clasz)
Returns the package path of a class. |
static java.lang.String |
getRelativePath(java.io.File baseDir,
java.io.File dir)
Returns a relative path based on a base directory. |
static java.net.URL |
getResource(java.lang.Class clasz,
java.lang.String name)
Get the path to a resource located in the same package as a given class. |
static java.util.Properties |
loadProperties(java.lang.Class clasz,
java.lang.String filename)
Load properties from classpath. |
static java.util.Properties |
loadProperties(java.io.File file)
Load properties from a file. |
static java.util.Properties |
loadProperties(java.net.URL baseUrl,
java.lang.String filename)
Load a file from an directory. |
static void |
saveProperties(java.io.File file,
java.util.Properties props,
java.lang.String comment)
Save properties to a file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String getPackagePath(java.lang.Class clasz)
clasz - Class to determine the path for.
public static java.net.URL getResource(java.lang.Class clasz,
java.lang.String name)
clasz - Class with the same package where the resource is located.name - Filename of the resource.
public static java.util.Properties loadProperties(java.lang.Class clasz,
java.lang.String filename)
clasz - Class in the same package as the properties file.filename - Name of the properties file (without path).
public static java.util.Properties loadProperties(java.io.File file)
file - Properties file.
public static void checkValidFile(java.io.File file)
IllegalArgumentException is thrown.
file - File to check.public static void checkValidDir(java.io.File dir)
IllegalArgumentException is thrown.
dir - Directory to check.
public static void saveProperties(java.io.File file,
java.util.Properties props,
java.lang.String comment)
file - Destination file.props - Properties to save.comment - Comment for the file.public static java.lang.Object createInstance(java.lang.String className)
className - Full qualified class name.
public static void addToClasspath(java.lang.String url)
url - URL to add.
public static boolean containsURL(java.net.URL[] urls,
java.net.URL url)
urls - Array of URLs.url - URL to find.
public static java.lang.String createHash(java.io.File file)
file - File to create an hash for.
public static java.net.URL createUrl(java.net.URL baseUrl,
java.lang.String path,
java.lang.String filename)
baseUrl - Directory URL.path - Relative path inside the base URL.filename - Filename without path.
public static java.lang.String getRelativePath(java.io.File baseDir,
java.io.File dir)
dir is not inside baseDir an
IllegalArgumentException is thrown.
baseDir - Base directory the path is relative to.dir - Directory inside the base directory.
dir relative to baseDir. If
both are equal an empty string is returned.
public static java.util.Properties loadProperties(java.net.URL baseUrl,
java.lang.String filename)
baseUrl - Directory URL.filename - Filename without path.
public static void addToClasspath(java.net.URL url)
url - URL to add.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||