Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
814 views
in Technique[技术] by (71.8m points)

windows - When does System.getProperty("java.io.tmpdir") return "c: emp"

Just curious as to when System.getProperty("java.io.tmpdir") returns "c:emp". According to the java.io.File Java Docs-

The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "c:emp". A different value may be given to this system property when the Java virtual machine is invoked, but programmatic changes to this property are not guaranteed to have any effect upon the the temporary directory used by this method.

But in my case-

System.out.println(System.getProperty("java.io.tmpdir"));

Always returns-

C:UsersadminAppDataLocalTemp i.e. %TEMP%

In what conditions will it return "c:emp"?

EDITED: If I change %TEMP% to C:Temp then I will get C:Temp, right? But the documentation shows c:Temp instead of C:Temp.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In MS Windows the temporary directory is set by the environment variable TEMP. In XP, the temporary directory was set per-user as Local SettingsTemp.

If you change your TEMP environment variable to C:emp, then you get the same when you run :

System.out.println(System.getProperty("java.io.tmpdir"));


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...