file hashCode Example
file class hashCode example. This example shows you how to use hashCode method.
File class hashCode example.method computes hash code values of files and directories taken.method returns integer representations of the pathnames of files or directories. this is necessary because to check the equality of abstract pathnames with varying operating systems is not appropriate every time, but with these hash code tools it is possible & plausible everytime .method is called with a File class object.
Here is the code:-
/**
* @Program uses hashCode method to compute the hash code
* of abstract pathnames of directories and files.
* HashCode.java
* Author:-RoseIndia Team
* Date:-30-june-2008
*/
import java.io.File;
import java.io.IOException;
public class HashCode {
public static void main(String args[]) throws IOException {
File guilty = new File("/home/mahendra/Desktop/limca.txt"),
sculpture = new File("/tmp/media.tmp");
sculpture.createNewFile();
int space = guilty.hashCode(), cosmos = sculpture.hashCode();
System.out.println("Hash codes generated\n"+ space + "\n" + cosmos);
}
} |
Output of the program:-
Hash codes generated
1205679732
1322595543 |
|