public abstract class Places extends Object
FileUtil.getConfigFile
to find a file declared in an XML layer or created or overridden in the config subdirectory of the user directory.
InstalledFileLocator to find modules installed as part of an NBM.
someClass.getProtectionDomain().getCodeSource().getLocation() to find resources inside a module class loader.
| Modifier | Constructor and Description |
|---|---|
protected |
Places()
Constructor for those who believe to know
where
Places.getCacheDirectory() or
Places.getUserDirectory() is. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract File |
findCacheDirectory()
The cache directory to return from
Places.getCacheDirectory(). |
protected abstract File |
findUserDirectory()
Finds location of a user directory to return from
Places.getUserDirectory(). |
static File |
getCacheDirectory()
Locates the NetBeans cache directory.
|
static File |
getCacheSubdirectory(String path)
Convenience method to get a particular subdirectory within
Places.getCacheDirectory(). |
static File |
getCacheSubfile(String path)
Convenience method to get a particular file within
Places.getCacheDirectory(). |
static File |
getUserDirectory()
Locates the NetBeans user directory.
|
protected Places()
Places.getCacheDirectory() or
Places.getUserDirectory() is. Register your subclass via
ServiceProvider annotation.public static File getUserDirectory()
FileUtil.getConfigFile) is inappropriate due its being virtual.
Each module is responsible for using sufficiently unique filenames within this directory.
The system property netbeans.user is used for compatibility.public static File getCacheDirectory()
$userdir/var/cache/ is used as a default when Places.getUserDirectory() is configured.
As a final fallback, a location in the system temporary directory will be returned.Places.getCacheSubdirectory(java.lang.String),
Places.getCacheSubfile(java.lang.String)public static File getCacheSubdirectory(String path)
Places.getCacheDirectory().
The directory will be created if it does not yet exist (but a warning logged if permissions do not allow this).path - a subdirectory path such as stuff or mymodule/stuff (/ permitted even on Windows)public static File getCacheSubfile(String path)
Places.getCacheDirectory().
The parent directory will be created if it does not yet exist (but a warning logged if permissions do not allow this);
the file itself will not be automatically created.path - a file path such as stuff.ser or mymodule/stuff.ser (/ permitted even on Windows)protected abstract File findCacheDirectory()
Places.getCacheDirectory().
If null the caches will be placed below Places.getUserDirectory().protected abstract File findUserDirectory()
Places.getUserDirectory().null if no user directory is
supposed to be used