How to get the identity hash codes for files
publicstaticvoid main(String[] args){
File file1 = new File("a");
File file2 = new File("b");
File file3 = new File("c");
int ihc1=System.identityHashCode(file1);
int ihc2=System.identityHashCode(file2);
int ihc3=System.identityHashCode(file3);
System.out.println(ihc1);
System.out.println(ihc2);
System.out.println(ihc3);
}
Output:
169174794
52414130
455987640
本文介绍了一种使用Java编程语言获取文件身份哈希码的方法。通过实例演示了如何为不同的文件生成唯一的整数标识符,这对于文件比较及内存中对象唯一性验证非常有用。
846

被折叠的 条评论
为什么被折叠?



