首页  

判断文件是否是符号链接     所属分类 java 浏览量 1148
做了一个小工具,统计指定文件类型的代码行数,
结果死循环,无法退出,原来是目录里存在符号链接,导致死循环

判断文件是否符号链接

	public static boolean isSymlink(File file) throws IOException {
		if (file == null){
			return false;
		}
		File canon;
		if (file.getParent() == null) {
			canon = file;
		} else {
			File canonDir = file.getParentFile().getCanonicalFile();
			canon = new File(canonDir, file.getName());
		}
		return !canon.getCanonicalFile().equals(canon.getAbsoluteFile());
	}
	
忽略符号链接文件

上一篇     下一篇
企业分析要点

linux打开文件最大数设置

JVM中的对象内存布局

maven clean package install deploy区别

jar冲突处理

java对象访问方式