Writing temp files on domino server using java: what is the best practice for the temp directory?

心不动则不痛 提交于 2019-12-11 07:52:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!