What is the best way to find the users home directory in Java?

后端 未结 9 738
清歌不尽
清歌不尽 2020-11-22 09:12

The difficulty is that it should be cross platform. Windows 2000, XP, Vista, OSX, Linux, other unix variants. I am looking for a snippet of code that can accomplish this for

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 09:57

    Others have answered the question before me but a useful program to print out all available properties is:

    for (Map.Entry e : System.getProperties().entrySet()) {
        System.out.println(String.format("%s = %s", e.getKey(), e.getValue())); 
    }
    

提交回复
热议问题