Temp folder and platform independence
I just discovered that
System.getProperty("java.io.tmpdir","");
returns on windows with a path separator at the end and on linux without which definitely makes a difference.
So this property affects platform independency of an application written in java.
Or is there something I missed?
[368 byte] By [
mwildama] at [2007-11-27 11:04:40]

output on Windows (e.g.): C:\Temp\
output on Linux (e.g.): /tmp
So when on linux I have to add a path separator and on windows I may not add it.
It depends on whether you read "platform independence" as "completely transparent platform independence". There are a few gotchas, such as this, that you should account for
:-( - This is a trap one easily could fall into and it would be so easy to remove that problem by taking into consideration when reading this information within the JVM.
Is there somewhere a list out there of "known issues" that affect platform independence like this?
import java.io.*;
class Foo {
public static void main(String[] args) throws Exception {
String tempdir = System.getProperty("java.io.tmpdir","");
String filename = "temp.txt";
File f = new File(tempdir, filename);
System.out.println(f.getAbsolutePath());
}
}
My results on Windows:
C:\DOCUME~1\yawmark\LOCALS~1\Temp\temp.txt
On Linux (Fedora Core 7):
/tmp/temp.txt
No added (or omitted) slashes necessary.
~