Location of Temp Directory?

B

Barkster

I'm having an app developed for me and they are storing the files in a
newly created folder on the C: drive but I don't want to make directory
there. Is there not a way to get the temp variable for machine, like
%temp or %tmp? Thanks
 
R

Real Gagnon

I'm having an app developed for me and they are storing the files in a
newly created folder on the C: drive but I don't want to make directory
there. Is there not a way to get the temp variable for machine, like
%temp or %tmp? Thanks

( http://www.rgagnon.com/javadetails/java-0484.html )

String tempdir = System.getProperty("java.io.tmpdir");

if ( !(tempdir.endsWith("/") || tempdir.endsWith("\\")) )
tempdir = tempdir + System.getProperty("file.separator");

Bye.
 
C

Chris Smith

Real said:
String tempdir = System.getProperty("java.io.tmpdir");

Or File.createTempFile is often better, depending on the situation.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
B

Barkster

Thanks guys, I think my devoloper just copied some code over I would
hope he would have know this. Appreciate it.
 
S

Steve W. Jackson

Barkster said:
Does this work on win and mac? Thanks

It works with all platforms. The java.io.tmpdir property tells you
where the JVM will store temporary files and is set by the
implementation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top