开发者

java user.home to return in local language

开发者 https://www.devze.com 2023-01-05 09:32 出处:网络
When I run System.getProperty(\"user.home\") on turkish windows 7, I get \"C:\\Users\\aaaa\" ev开发者_如何学JAVAen though \"Users\" folder does not exist in my computer (I have the turkish translation

When I run System.getProperty("user.home") on turkish windows 7, I get "C:\Users\aaaa" ev开发者_如何学JAVAen though "Users" folder does not exist in my computer (I have the turkish translation of "users"). How can I get the correct user.home information? Thank you


Which version of Windows are you running? On Vista and above (2008, 2008R2, Windows7), the folder is called Users in the file system, irrespective of the current language. But Windows Explorer displays it in the language of the UI, "Benutzer" (German) in my case. You can check in a command window that the real name of this folder is Users.


even though "Users" folder does not exist in my computer (I have the turkish translation of "users").

That's not true. You have the "Users" folder. Windows just automatically translates it when displaying it. But you have to use "Users" for filesystem paths, which is what user.home returns. The localized name is only relevant for displaying it to the user. I'm not sure how to get it from Java code.

Frankly, I think the whole concept of displaying different folder names to the user than what is actually present in the filesystem is a bizarre perversion.

0

精彩评论

暂无评论...
验证码 换一张
取 消