Get Desktop directory OS-independent

元气小坏坏 提交于 2019-12-07 13:04:39

问题


Of course I could use

File desktop = new File(System.getProperty("user.home") + "/Desktop"));

but this would only work OS-independent if the OS is set to English locale... On Windows the Desktop is named Desktop in every language it was translated to, but e.g. on Ubuntu the Desktop name gets translated (On my German system it's Arbeitsfläche).

So I'm looking for an OS- and Locale-independent way of getting a File object representing the desktop directory.

来源:https://stackoverflow.com/questions/20910986/get-desktop-directory-os-independent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!