在tomcat上保存临时文件的最佳实践? [英] Best practice to save temp files on tomcat?

查看:574
本文介绍了在tomcat上保存临时文件的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要演示一个基于xml的数据交换系统。它在学校的可信计算机上进行离线演示。该应用程序将在稍后获取数据库,但仅针对此演示文稿我只需要显示xml文件的布局,打开和保存以及表如何从xml获取数据。

I need to demo a xml based data interchange system. It is demoed offline on a trusted computer at school. The application will get database later but just for this presentation I only need to show the layout, opening and saving of xml-files and how the table gets data from the xml.

那么,什么是让网络应用程序暂时创建xml文件的最佳位置,以便我可以展示这个应用程序?我正在使用Eclipse和Tomcat。

So, what would be the best location to let the web app create the xml files temporarily so I can showcase this app? I'm using Eclipse and Tomcat.

如上所述,安全性根本不是问题,因为此版本不会在线。此外,如果每次运行应用程序都会删除文件,那么就可以了。

As mentioned, security is not an issue at all, since this version is NOT going to be online. Also, it's ok if the files get erased each time the application is run.

它们只需要在演示期间存在应用程序运行一次。所以,我不知道什么是最好的位置以及如何获得这种位置的路径而不依赖于所使用的计算机。

They need to exist only for the duration of the presentation where the application is run once. So, I'm clueless what would be the best location and how to get the path to such location not depending on the computer used.

谢谢。

推荐答案

使用属性 java.io.tmpdir 获取 tomcat 临时文件夹并将文件保存在那里。这将是暂时保留它们的好地方。所以你可以按如下方式定义它:

Use the property java.io.tmpdir to get the tomcat temp folder and save your files there. That will be a good place to temporarily keep them in. So you can define it as follows:

public static final String TMP_DIR = System.getProperty("java.io.tmpdir")

这篇关于在tomcat上保存临时文件的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆