zhyiwww
用平实的笔,记录编程路上的点点滴滴………
posts - 536,comments - 394,trackbacks - 0

A filename path may include redundant names such as `.' or `..' or symbolic links (on UNIX platforms). File.getCanonicalFile() converts a filename path to a unique canonical form suitable for comparisons.

				
						    File file1 = new File("./filename");
    File file2 = new File("filename");
    
    // Filename paths are not equal
    boolean b = file1.equals(file2);      // false
    
    // Normalize the paths
    try {
        file1 = file1.getCanonicalFile(); // c:\almanac1.4\filename
        file2 = file2.getCanonicalFile(); // c:\almanac1.4\filename
    } catch (IOException e) {
    }
    
    // Filename paths are now equal
    b = file1.equals(file2);              // true
				
		


|----------------------------------------------------------------------------------------|
                           版权声明  版权所有 @zhyiwww
            引用请注明来源 http://www.blogjava.net/zhyiwww   
|----------------------------------------------------------------------------------------|
posted on 2006-06-13 11:56 zhyiwww 阅读(247) 评论(0)  编辑  收藏 所属分类: code demo -java

只有注册用户登录后才能发表评论。


网站导航: