Getting My Documents path in Java

后端 未结 8 1323
孤城傲影
孤城傲影 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 05:20

    Using JNA you would do this:

    String myDocsPath = Shell32Util.getFolderPath(ShlObj.CSIDL_PERSONAL);
    

    JNA extracts a DLL on-the-fly and then uses JNI with this DLL to make Windows API calls. It hides all the JNI details from you though. Using JNA is as easy as using any other java library JAR.

提交回复
热议问题