下面列出了java.io.File#hashCode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Returns a hash code value for this {@code Redirect}.
* @return a hash code value for this {@code Redirect}
*/
public int hashCode() {
File file = file();
if (file == null)
return super.hashCode();
else
return file.hashCode();
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
/**
* Returns a hash code value for this {@code Redirect}.
* @return a hash code value for this {@code Redirect}
*/
public int hashCode() {
File file = file();
if (file == null)
return super.hashCode();
else
return file.hashCode();
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
/**
* Returns a hash code value for this {@code Redirect}.
* @return a hash code value for this {@code Redirect}
*/
public int hashCode() {
File file = file();
if (file == null)
return super.hashCode();
else
return file.hashCode();
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
/**
* Returns a hash code value for this {@code Redirect}.
* @return a hash code value for this {@code Redirect}
*/
public int hashCode() {
File file = file();
if (file == null)
return super.hashCode();
else
return file.hashCode();
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
static void test(String fn1, String fn2) throws Exception {
File f1 = new File(fn1);
File f2 = new File(fn2);
if (!f1.equals(f2))
throw new Exception("Instances with equal paths are not equal");
int h1 = f1.hashCode();
int h2 = f2.hashCode();
if (h1 != h2)
throw new Exception("Hashcodes of equal instances are not equal");
}
private String createName(File file){
String realName = "u"+UID+System.currentTimeMillis()+file.hashCode()+".jpg";
return realName;
}
public WeakFileEntry(File entry)
{
// file object with 2 fields, string object with 2 fields, char-array object
super(entry, entry.hashCode(), 16 + 16 + 8 + entry.getPath().length() * 2);
}
private static Object getFileLock(final File file) {
return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
private static Object getFileLock(final File file) {
return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
private static Object getFileLock(final File file) {
return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
private static Object getFileLock(final File file) {
return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
private static Object getFileLock(final File file) {
return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}