Java Root Directory Get getRoot(File file)

Here you can find the source of getRoot(File file)

Description

get Root

License

Apache License

Parameter

Parameter Description
file a parameter

Declaration

public static File getRoot(File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**/*from  ww  w  .  j  a v a2s . c  o m*/
     * @param file
     * @return
     */
    public static File getRoot(File file) {
        File parent = file;
        while (parent.getParentFile() != null)
            parent = parent.getParentFile();

        return parent;
        // return file without parent (aka root)
    }
}

Related

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