问题
I am writing a Java Agent which does some attachment manipulations and I am looking for a 'clean' place where I can do the manipulations - i.e. won't have too much hassles with admins setting special permissions. Is there a best practise for the location of the temp directory? In Lotusscript I would use
Environ("Temp")
which would give me the temp directory of the local machine.
There is also the possibility of using the data directory, but that makes me uneasy...
var d = session.getEnvironmentString("directory",true)
Any tips/best recommendations?
回答1:
The general rule is if you need a temp directory, then request it from the system.
Example:
System.getProperty("java.io.tmpdir")
Using the Data folder is probably going to upset the admin.
If you want to create diagnostic logs which you may use later then I recommend writing to:
<DOMINO DATA FOLDER>\IBM_TECHNICAL_SUPPORT
This way the admin has one set place to find logs.
回答2:
An example could be
File temp = File.createTempFile("temp-file-name", ".tmp");
temp.deleteOnExit(); //This will delete the file when the JVM shuts down.
That file would be saved in
C:\Users\*User*\AppData\Local\Temp\temp-file-name623426.tmp
来源:https://stackoverflow.com/questions/19047154/writing-temp-files-on-domino-server-using-java-what-is-the-best-practice-for-th