Java windows用户文件夹(如果应用程序从服务器运行)

Java windows用户文件夹(如果应用程序从服务器运行),java,windows,Java,Windows,在用户文件夹中创建文件的最佳方式是什么?应用程序保存在共享位置的服务器上,但文件必须存储在他们使用的计算机中。他们在不同的计算机上运行此应用程序,但都安装了Windows(xp和7) 我当前的方法如下所示: public static String getDocumentsFolder() { String myDocuments = null; try { Process p = Runtime.getRuntime().exec("reg query \"H

在用户文件夹中创建文件的最佳方式是什么?应用程序保存在共享位置的服务器上,但文件必须存储在他们使用的计算机中。他们在不同的计算机上运行此应用程序,但都安装了Windows(xp和7)

我当前的方法如下所示:

public static String getDocumentsFolder() {
    String myDocuments = null;
    try {
        Process p =  Runtime.getRuntime().exec("reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\" /v personal");
        if (p.waitFor()==0) {
            InputStream in = p.getInputStream();
            byte[] b = new byte[in.available()];
            in.read(b);
            in.close();
            myDocuments = new String(b);
            myDocuments = myDocuments.split("\\s\\s+")[4];
        } else {
            //nothing for now...
        }
        myDocuments+="\\MyApp";
        new File(myDocuments).mkdirs();
    } catch(Exception e) {
        ErrorHandler.handle(e);
    }
    return myDocuments;
}
非常感谢您的帮助!感谢使用System.getProperty(“user.home”)