Getting My Documents path in Java

后端 未结 8 1289
孤城傲影
孤城傲影 2020-12-06 04:21

I need to find my documents path using Java. The following code doesn\'t give me \"accurate\" loation

System.getProperty(\"user.home\");

What sh

8条回答
  •  太阳男子
    2020-12-06 04:56

    "user.home" returns the home directory of the user, not the "My Documents" folder. On Windows, it would be "C:\Users\Username\" for Vista or 7, or "C:\Documents and Settings\Username" for XP

    What you want is:

    System.out.println(System.getProperty("user.home") + File.separatorChar + "My Documents");
    

提交回复
热议问题