First, use System.getProperty("user.home") to get the "user" directory...
String path = System.getProperty("user.home") + File.separator + "Documents"; File customDir = new File(path);
Second, use File#mkdirs instead of File#mkdir to ensure the entire path is created, as mkdir assumes that only the last element needs to be created
Now you can use File#exists to check if the abstract path exists and if it doesn't File#mkdirs to make ALL the parts of the path (ignoring those that do), for example...
if (customDir.exists() || customDir.mkdirs()) { // Path either exists or was created } else { // The path could not be created for some reason }
Updated
A simple break down of the various checks that might need to be made. The previous example only cares if the path exists OR it can be created. This breaks those checks down so that you can see what's happening...
String path = System.getProperty("user.home") + File.separator + "Documents"; path += File.separator + "Your Custom Folder" File customDir = new File(path); if (customDir.exists()) { System.out.println(customDir + " already exists"); } else if (customDir.mkdirs()) { System.out.println(customDir + " was created"); } else { System.out.println(customDir + " was not created"); }
Note, I've added an additional folder called Your Custom Folder to the path ;)
File SimpleHTML = new File("C:/Users/"+user+"/Documents"); {, add those plus to concat 2 string