Here is the code I use, you can use it if you want:
public FileManager () {
String FileFolder = System.getenv("APPDATA") + "\\" + "Launcher"; System.out.println("Searching for system"); String os = System.getProperty("os.name").toUpperCase(); if (os.contains("WIN")) { FileFolder = System.getenv("APPDATA") + "\\" + "Launcher"; System.out.println("Found windows"); } if (os.contains("MAC")) { FileFolder = System.getProperty("user.home") + "/Library/Application " + "Support" + "Launcher"; System.out.println("Found mac"); } if (os.contains("NUX")) { FileFolder = System.getProperty("user.dir") + ".Launcher"; System.out.println("Found linux"); } System.out.println("Searching for resource folder"); File directory = new File(FileFolder); if (directory.exists()) { System.out.println("Found folder"); } if (directory.exists() == false) { directory.mkdir(); System.out.println("Could not find folder so created it"); }
}
Check only on Windows, can anyone check it on mac / Linux?
source share