File hashCode() in Java

hashCode(): This method is available in the java.io.File class of Java.

Syntax:

int java.io.File.hashCode()

This method computes a hash code for this abstract pathname.

Note:

1. On UNIX systems, the hash code of an abstract pathname is equal to the exclusive or of the hash code of its pathname string and the decimal value 1234321.

2. On Microsoft Windows systems, the hash code is equal to the exclusive or of the hash code of its pathname string converted to lower case and the decimal value 1234321.

3. Locale is not taken into account on the lower casing of the pathname string.

Parameters: NA

Returns: A hash code for this abstract pathname.

Exceptions: NA

Approach

Java

import java.io.File;

public class FilehashCode {
    public static void main(String[] args) {

        String pathname = "D:\\hello.txt";
        File file = new File(pathname);

        System.out.println(file.hashCode());
    }
}

Output:

-825352481


No comments:

Post a Comment