Skip to content

Instantly share code, notes, and snippets.

@Cakemix1337
Created April 20, 2012 09:28
Show Gist options
  • Save Cakemix1337/2427327 to your computer and use it in GitHub Desktop.
Save Cakemix1337/2427327 to your computer and use it in GitHub Desktop.
%appdata% finder
private File appFileFinder(String folder, String file) {
String OS = System.getProperty("os.name").toUpperCase();
if (OS.contains("WIN")) {
if (new File(System.getenv("APPDATA")).exists()) {
if (!new File(System.getenv("APPDATA") + "/"+folder).exists()) {
new File(System.getenv("APPDATA") + "/"+folder).mkdirs();
}
return new File(System.getenv("APPDATA") + "/"+folder+"/" );
}
return new File(file);
} else if (OS.contains("MAC")) {
if (new File(System.getProperty("user.home") + "/Library/Application Support").exists()) {
if (!new File(new File(System.getProperty("user.home") + "/Library/Application Support") + "/"+folder).exists()) {
new File(new File(System.getProperty("user.home") + "/Library/Application Support") + "/"+folder).mkdirs();
}
return new File(new File(System.getProperty("user.home") + "/Library/Application Support") +"/"+folder+"/" );
}
return new File(file);
}
return new File(file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment