java.io.File and properties

Michael Koch konqueror@gmx.de
Fri May 9 11:13:00 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Freitag, 9. Mai 2003 07:00 schrieb Ranjit Mathew:
> > Michael> I have question: java.io.File initializes a static
> > variable called Michael> tmpdir at class initialization with the
> > value of the property Michael> "java.io.tmpdir". If an app
> > changes the value of this property after Michael>
> > java.io.File.tmpdir has been initialized java.io.File will use
> > the Michael> old value.
> >
> > What does the JDK do?
>
> Given the following program:
> -------------------------------- 8<
> -------------------------------- import java.util.*;
> import java.io.*;
>
> public class T {
>   public static void main( String[] args) throws Exception {
>       System.out.println( System.getProperty( "java.io.tmpdir"));
>       System.out.println( File.createTempFile( "java", null));
>
>       Properties props = System.getProperties( );
>       props.put( "java.io.tmpdir", "C:\\TEMP\\");
>
>       System.out.println( System.getProperty( "java.io.tmpdir"));
>       System.out.println( File.createTempFile( "mocha", null));
>   }
> }
> -------------------------------- 8<
> --------------------------------
>
> JRE 1.4.1_01 on Windows gives the following output:
> -------------------------------- 8<
> -------------------------------- D:\TEMP\
> D:\TEMP\java35585.tmp
> C:\TEMP\
> D:\TEMP\mocha35586.tmp
> -------------------------------- 8<
> --------------------------------
>
> So while the change to "java.io.tmpdir" is noted, temporary files
> are *still* created in the original temporary folder.
>
> So is this is a bug in Classpath?

On Linux JRE 1.4.1_01 behaves the same as on Windows. (*wonder* ;-))

The question is: Should we emulate this behaviour or do it the 
classpath way ?

If we wanna do it the JRE way I will speak with Brian Jones about to 
change classpath's behaviour.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+u0jtWSOgCCdjSDsRAoZ7AJ4/XsdQxQ6HHi9wsX7kiIXNRwI5QACfVC/6
CizcffegSpDNLYVcOidEGR0=
=LZr6
-----END PGP SIGNATURE-----



More information about the Java mailing list