I am trying to save some user settings in the home/appdata folder, but when I use dir.canwrite() it returns false. This is the code I use to determine the home/appdata folder:
public static String getAppDataPath() {
if (System.getProperty("os.name").contains("Windows")) {
return System.getenv("APPDATA");
} else {
return getUnixHome();
}
}
public static String getUnixHome() {
String home = System.getProperty("user.home");
return home != null ? home : "~";
}
And this is the code trying to mkdir:
public static boolean checkExistenceDir(String path) {
File dir = new File(path);
if(!dir.exists()) {
dir.mkdir();
}
}
The path in question is:
getAppDataPath() + ".foo" + File.separatorChar