if(isRootDirectory(path)) return path;
  public static final String toCanonicalForm(String path)  {    /*??    if(path.indexOf('.') < 0 && path.indexOf("..") < 0)            return path;		 */		String tmppath = path.replace('/', separatorChar);		StringBuffer canonpath;		// We found it'll be more efficient and easy to handle to		// return a lowercased canonical path    if(isWindows)			tmppath = tmppath.toLowerCase();		int i;    if ((i = beginWithRootPathPrefix(tmppath)) == 0 )			return path;    /* The original            "canonpath = new StringBuffer(tmppath.substring(0, i))"       isn't very efficient because StringBuffer's        ensureCapacity_unsynchronized will fail definitely each time        and will enlarge buffer and copy contents.       .		 */		canonpath = new StringBuffer(INITIAL_MAX_PATH);		canonpath.append(tmppath.substring(0, i));		tmppath = tmppath.substring(i);		// pathdepth==0 indicates there're only root path in the buffer		int pathdepth = 0;		StringTokenizer st = new StringTokenizer(tmppath, separator);		// Traverse each element of the path, handling "." and ".."		// Should handle "~" too?		if (st.hasMoreTokens())      do        {				String s = st.nextToken();				// Handle "." or an empty element.				if (s.equals(".") || s.equals(""))					continue;				// Handle ".." by deleting the last element from the path          if (s.equals(".."))            {					if (pathdepth == 0)						continue;					// Strip of trailing separator              canonpath.setLength(canonpath.length() - 1/*separator.length()*/);					String tmpstr = canonpath.toString();					int idx = tmpstr.lastIndexOf(separator);              if ((idx == -1) || ((idx + 1/*separator.length()*/) > tmpstr.length()))						//throw new IOException("Can't happen error");						return path; // Shouldn't happen              canonpath.setLength(idx + 1/*separator.length()*/);					pathdepth--;					continue;				}				canonpath.append(s);				pathdepth++; //now it's more than root path				if (st.hasMoreTokens())					canonpath.append(separator);        }      while (st.hasMoreTokens());		if (endWithSeparator(path))			canonpath.append(separator);		String tmpstr = canonpath.toString();		//if (pathdepth > 0 && endWithSeparator(tmpstr) )    //    tmpstr = tmpstr.substring(0, tmpstr.length() - 1/*separator.length()*/);		return tmpstr;	}