Here you can find the source of getRoot(File file)
public static File getRoot(File file)
//package com.java2s; import java.io.File; public class Main { public static File getRoot(File file) { File tmp = file.getParentFile(); File rtn = null;//from w ww . j a v a2 s .c o m for (; tmp != null; rtn = tmp, tmp = tmp.getParentFile()) ; return rtn; } }