Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows temp directory details (Java)

I'm writing a program that needs a generic temp folder. I'm trying to find details about the Windows Temp folders. There are two paths that I know about -

  1. In each user directory under AppData\Local\Temp\ This may change depending Windows version?

  2. In the system folder under Temp\ (C:\Windows\Temp)

I'm wondering exactly what Windows does to each of these. If Windows deletes files from either location, when does it do so? How can/should I use these directories for my programming?

EDIT: I have a bigger problem actually - Because of a certain engine I'm running indirectly with my program, which uses files I'm creating in a temp directory, I need a temp directory that doesn't use whitespace characters in the path. Java's System.getProperty("java.io.tmpdir") on Windows gives me the temp that's in the user directory, which on XP is under "Documents and Settings..." Not good. Any suggestions? This is why I'm wondering about the C:\Windows\Temp\ directory...

like image 394
Tony R Avatar asked Aug 09 '10 03:08

Tony R


1 Answers

This will give you the path to the windows temp directory in Java.

File.createTempFile("temp-file", "tmp").getParent()
like image 183
chinto Avatar answered Nov 07 '22 01:11

chinto