Java Code Examples for java.io.File#hashCode()

The following examples show how to use java.io.File#hashCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessBuilder.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 2
Source File: HashCodeEquals.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 3
Source File: HashCodeEquals.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 4
Source File: ProcessBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 5
Source File: HashCodeEquals.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 6
Source File: ProcessBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 7
Source File: HashCodeEquals.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 8
Source File: HashCodeEquals.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 9
Source File: HashCodeEquals.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 10
Source File: ProcessBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 11
Source File: HashCodeEquals.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 12
Source File: HashCodeEquals.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 13
Source File: HashCodeEquals.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 14
Source File: OptimisticTypesPersistence.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
 
Example 15
Source File: OptimisticTypesPersistence.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
 
Example 16
Source File: OptimisticTypesPersistence.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
 
Example 17
Source File: OptimisticTypesPersistence.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
 
Example 18
Source File: StringInterner.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 19
Source File: ImageModel.java    From Fishing with GNU General Public License v3.0 4 votes vote down vote up
private String createName(File file){
    String realName = "u"+UID+System.currentTimeMillis()+file.hashCode()+".jpg";
    return realName;
}
 
Example 20
Source File: OptimisticTypesPersistence.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}