Unlike C, Java 1.1 does not have methods for generating unique temporary filenames. I have written a getTempFile method.
Here is a slightly smarter version of Java 1.2+’s File.createTempFile() that will let you specify either a directory to create the temp file in, or a file in whose directory to create the file in. You need the logic of this smarter version if you want to write a utility that replaces the input file with the processed output from a renamed temp file.
I am using Vista and I am horrified to discover than even after 25 years Microsoft still does not understand the temporary files problem.
When a program crashes, it does not delete its temporary files. Over the years your disk fills with junk.
Windows does not:
Here are three ways we could handle the probem of orphaned temporary files:
To use tmpfs, make sure your kernel can handle 'tmpfs', then add the following line into /etc/fstab:
tmpfs /tmp tmpfs noatime,mode=1777 0 0 then either reboot or 'init s’ then 'init {runlevel}', depending on preferences and OS configuration. (Don’t just mount /tmp unless you’re sure nothing is using it. X in particular sticks files in there — /tmp/.X11-unix/Xn, presumably for its Unix sockets.)
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.62] | The information on this page is for non-military use only. | ||
| You are visitor number 13,335. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | ||
| http://mindprod.com/jgloss/temporaryfiles.html | J:\mindprod\jgloss\temporaryfiles.html | ||