[ACCEPTED]-Best practice to save temp files on tomcat?-temp
Use the property java.io.tmpdir
to get the tomcat
temp folder 3 and save your files there. That will be 2 a good place to temporarily keep them in. So 1 you can define it as follows:
public static final String TMP_DIR = System.getProperty("java.io.tmpdir")
Either use the property java.io.tmpdir
as indicated or 5 use the servlet context attribute javax.servlet.context.tempdir
defined 4 in the specification. For tomcat that attribute 3 can be changed by the workDir attribute 2 on the context.
You can use that attribute 1 by a call to servletContext.getAttribute("javax.servlet.context.tempdir")
Old question, but if there is for creating 1 temp file why not use File.createTempFile
function?
Example:
File temp = File.createTempFile("real",".howto");
temp.deleteOnExit();
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.