public final class FileLocator extends Object
Modifier and Type | Method and Description |
---|---|
static InputStream |
getAsStream(Class<?> clazz,
String location) |
static InputStream |
getAsStream(String location) |
static String |
getFullPath(Class<?> clazz,
String relativePath)
Attempts to discover the real location of a file pointed to by relativePath.
|
static String |
getFullPath(String relativePath)
Attempts to discover the real location of a file pointed to by relativePath.
|
static String |
getFullPathQuiet(Class<?> clazz,
String relativePath)
QUIETLY Attempts to discover the real location of a file pointed to by relativePath.
|
static String |
getFullPathQuiet(String relativePath)
QUIETLY Attempts to discover the real location of a file pointed to by relativePath.
|
static File |
locateFile(Class<?> clazz,
String location)
Where a Stream is usable, use
getAsStream(String) . |
static File |
locateFile(String location)
Where a Stream is usable, use
getAsStream(String) . |
public static InputStream getAsStream(String location) throws FileNotFoundException
location
- some string representing the full or partial location of a fileFileNotFoundException
- if no file could be foundpublic static InputStream getAsStream(Class<?> clazz, String location) throws FileNotFoundException
clazz
- some class whose classloader should be usedlocation
- some string representing the full or partial location of a fileFileNotFoundException
- if no file could be foundpublic static File locateFile(String location) throws FileNotFoundException
getAsStream(String)
.
Where a path String is usable, use getFullPath(String)
.location
- some string representing the full or partial location of a fileFileNotFoundException
- if no file can be locatedpublic static File locateFile(Class<?> clazz, String location) throws FileNotFoundException
getAsStream(String)
.
Where a path String is usable, use getFullPath(String)
.clazz
- some class whose classloader should be usedlocation
- some string representing the full or partial location of a fileFileNotFoundException
- if no file can be locatedpublic static String getFullPath(String relativePath) throws FileNotFoundException
1. By checking to see if the provided relative path is actually an absolute path 2. By checking within the ClassPath 3. By checking directly under the current working directory 4. By checking under $CTAKES_HOME 5. By traversing above the current working directory. Useful when running under a module directory in an IDE Example: cwd = /usr/bin/ctakes/ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin/ctakes will be checked for containment of the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned 6. By traversing above the current working directory and under a subdirectory ctakes/ Example: cwd = /usr/bin/my_custom_ctakes/my_ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin will be checked for containment of ctakes/ plus the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned
relativePath
- some relative path to a fileFileNotFoundException
- if the file cannot be foundpublic static String getFullPath(Class<?> clazz, String relativePath) throws FileNotFoundException
1. By checking to see if the provided relative path is actually an absolute path 2. By checking within the ClassPath 3. By checking directly under the current working directory 4. By checking under $CTAKES_HOME 5. By traversing above the current working directory. Useful when running under a module directory in an IDE Example: cwd = /usr/bin/ctakes/ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin/ctakes will be checked for containment of the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned 6. By traversing above the current working directory and under a subdirectory ctakes/ Example: cwd = /usr/bin/my_custom_ctakes/my_ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin will be checked for containment of ctakes/ plus the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned
clazz
- some class whose classloader should be usedrelativePath
- some relative path to a fileFileNotFoundException
- if the file cannot be foundpublic static String getFullPathQuiet(String relativePath)
1. By checking to see if the provided relative path is actually an absolute path 2. By checking within the ClassPath 3. By checking directly under the current working directory 4. By checking under $CTAKES_HOME 5. By traversing above the current working directory. Useful when running under a module directory in an IDE Example: cwd = /usr/bin/ctakes/ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin/ctakes will be checked for containment of the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned 6. By traversing above the current working directory and under a subdirectory ctakes/ Example: cwd = /usr/bin/my_custom_ctakes/my_ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin will be checked for containment of ctakes/ plus the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned
relativePath
- some relative path to a filepublic static String getFullPathQuiet(Class<?> clazz, String relativePath)
1. By checking to see if the provided relative path is actually an absolute path 2. By checking within the ClassPath 3. By checking directly under the current working directory 4. By checking under $CTAKES_HOME 5. By traversing above the current working directory. Useful when running under a module directory in an IDE Example: cwd = /usr/bin/ctakes/ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin/ctakes will be checked for containment of the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned 6. By traversing above the current working directory and under a subdirectory ctakes/ Example: cwd = /usr/bin/my_custom_ctakes/my_ctakes-module , relativePath = ctakes-other-module/more/file.ext The directory above cwd /usr/bin will be checked for containment of ctakes/ plus the relative path If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned
clazz
- some class whose classloader should be usedrelativePath
- some relative path to a fileCopyright © 2012-2017 The Apache Software Foundation. All Rights Reserved.