Find place for dedicated application folder

前端 未结 2 1887
逝去的感伤
逝去的感伤 2020-11-29 11:38

I\'m sorry if this title is badly named, I can\'t think of a better way to phrase it and so edits would be welcomed.

Most applications I\'ve seen that require hard d

2条回答
  •  遥遥无期
    2020-11-29 12:30

    The directory can be found with the method

    static String defaultDirectory() {
        String os = System.getProperty("os.name").toLowerCase();
        if (OS.contains("win"))
            return System.getenv("APPDATA");
        else if (OS.contains("mac"))
            return System.getProperty("user.home") + "/Library/Application Support";
        else if (OS.contains("nux"))
            return System.getProperty("user.home");
        else
            return System.getProperty("user.dir");
    }
    

    It is worth noting that on Linux any such folders should be hidden by beginning their name with .

    (Answer found from users CodeBunny and Denis Tulskiy on this post)

提交回复
热议问题