System.getProperty(" java.io.tmpdir")何时返回" c:\ temp" [英] When does System.getProperty("java.io.tmpdir") return "c:\temp"

查看:151
本文介绍了System.getProperty(" java.io.tmpdir")何时返回" c:\ temp"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好奇何时 System.getProperty(java.io.tmpdir)返回c:\ temp。根据 java.io.File Java Docs -

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


默认临时文件目录由系统属性java.io.tmpdir指定。在UNIX系统上,此属性的默认值通常为/ tmp或/ var / tmp;在Microsoft Windows系统上,它通常是c:\ temp。调用Java虚拟机时,可以为此系统属性赋予不同的值,但不保证对此属性的编程更改会对此方法使用的临时目录产生任何影响。

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:\temp". 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"));

始终返回 -

C:\Users\admin\AppData\Local\Temp\ i.e. %TEMP%

在什么条件下会返回c:\ temp

In what conditions will it return "c:\temp"?

编辑:如果我将%TEMP%更改为C:\ Temp,那么我将得到C:\ Temp,对吧?但文档显示c:\ Temp而不是C:\ Temp。

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.

推荐答案

在MS Windows中,临时目录由环境变量 TEMP 。在XP中,临时目录按用户设置为Local Settings \Temp。

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

如果将TEMP环境变量更改为 C:\\ \\ temp ,然后在运行时得到相同的结果:

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

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

这篇关于System.getProperty(" java.io.tmpdir")何时返回" c:\ temp"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆