Java Root Directory Get getRootDir()

Here you can find the source of getRootDir()

Description

Get root directory for current work directory

License

Open Source License

Declaration

public static String getRootDir() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static final String USER_DIR = "user.dir";

    /**//from w ww  .j  a  va 2 s  . com
     * Get root directory for current work directory
     * 
     * @return
     */
    public static String getRootDir() {
        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;
    }
}

Related

  1. getRoot(File file)
  2. getRoot(File file, ArrayList lst)
  3. getRoot(final File workingDirectory)
  4. getRoot(final String path)
  5. getRoot(String path)
  6. getRootDir()
  7. getRootDir()
  8. getRootDir()
  9. getRootDir()