You can use:
File udir = new File(System.getProperty("netbeans.user"));
or you can use:
FileObject root = Repository.getDefault().getDefaultFileSystem().getRoot();
File udir = FileUtil.toFile(root).getParentFile();
//notice get parent called on the File instance instead
//of the root FileObject as it is a root in the NB FileSystem
Now, in the second case the default file system currently points to a folder called config which
actually resides directly below the user directory (on the physical disk). If that were to change
in the future to be a sub-directory then it could cause problems. Probably the safest is to use
the property as it could always be set in the future to keep backwards compatibility much easier.
There is probably some other way, but these are the ones I know which currently work. So, for the
var/log directory you can do something like:
FileObject foUserDir = FileUtil.toFileObject(udir);
FileObject logDir = foUserDir.getFileObject("var/log");
FileUtil.createFolder(logDir, "yourOwnLogDir/someOtherFolderOrPath");
//create your files under your own special log direcotory
//or any number of directories however you see fit...
which should match what you wrote you were trying to achieve. If you have any other issues let us
know.
Wade
File udir = new File(System.getProperty("netbeans.user"));
or you can use:
FileObject root = Repository.getDefault().getDefaultFileSystem().getRoot();
File udir = FileUtil.toFile(root).getParentFile();
//notice get parent called on the File instance instead
//of the root FileObject as it is a root in the NB FileSystem
Now, in the second case the default file system currently points to a folder called config which
actually resides directly below the user directory (on the physical disk). If that were to change
in the future to be a sub-directory then it could cause problems. Probably the safest is to use
the property as it could always be set in the future to keep backwards compatibility much easier.
There is probably some other way, but these are the ones I know which currently work. So, for the
var/log directory you can do something like:
FileObject foUserDir = FileUtil.toFileObject(udir);
FileObject logDir = foUserDir.getFileObject("var/log");
FileUtil.createFolder(logDir, "yourOwnLogDir/someOtherFolderOrPath");
//create your files under your own special log direcotory
//or any number of directories however you see fit...
which should match what you wrote you were trying to achieve. If you have any other issues let us
know.
Wade