List of utility methods to do Root Directory Get
File | getRoot(final File workingDirectory) Gets the root (or project) directory of a project. File ref = workingDirectory; while (ref.getParentFile() != null && new File(ref.getParentFile(), POM_FILE).exists()) { ref = ref.getParentFile(); return ref; |
String | getRoot(final String path) It can be necessary to determine which is the root of a path. final File roots[] = listRoots(new File(path)); for (int i = 0; i < roots.length; i++) { if (path.startsWith(roots[i].getPath())) { return roots[i].getPath(); return path; |
String | getRoot(String path) It can be necessary to determine which is the root of a path. File file = new File(path); File[] roots = file.listRoots(); for (int i = 0; i < roots.length; i++) if (path.startsWith(roots[i].getPath())) return roots[i].getPath(); return path; |
String | getRootDir() get Root Dir File currentDir = new File("."); return currentDir.getCanonicalPath(); |
File | getRootDir() get Root Dir return getOmHome().getParentFile().getParentFile();
|
File | getRootDir() get Root Dir String rootDir = System.getProperty("user.home", "."); File rootFile = new File(rootDir, ".autotest"); if (!rootFile.isDirectory()) { rootFile.mkdirs(); return rootFile; |
File | getRootDir() get Root Dir File rootDir = new File(System.getProperty("user.dir")); File parentPom = new File(rootDir.getParent(), "pom.xml"); while (parentPom.exists()) { rootDir = rootDir.getParentFile(); parentPom = new File(rootDir.getParent(), "pom.xml"); return rootDir; |
String | getRootDir() Get root directory for current work directory String userDir = System.getProperty(USER_DIR); String rootDir = userDir.substring(0, userDir.indexOf(File.separator) + 1); if (!rootDir.endsWith(File.separator)) { rootDir += File.separator; return rootDir; |
File | getRootDir() get Root Dir if (rootDir == null) { rootDir = new File(System.getProperty("java.io.tmpdir") + File.separator + ".dorado.tmp"); if (!rootDir.exists()) { if (!rootDir.mkdirs()) { throw new IOException("Make directory \"" + rootDir.getAbsolutePath() + "\" failed."); } else if (!rootDir.isDirectory()) { throw new IOException("\"" + rootDir.getAbsolutePath() + "\" is not a directory."); ... |
File | getRootDir() get Root Dir String os = System.getProperty("os.name").toUpperCase(); if (os.contains("WIN")) { return new File(System.getenv("APPDATA"), "routeKIT"); } else if (os.contains("MAC")) { return new File(new File(new File(System.getProperty("user.home"), "Library"), "Application Support"), "routeKIT"); } else if (os.matches(".*N[IU]X.*")) { return new File(new File(System.getProperty("user.home"), ".config"), "routeKIT"); ... |