For the project I'm working on I need to locate the iNode/FileID. It is the unique identifier for individual files in the operating system so that I can keep track of them even if they are renamed or moved.
It was recommended that I use BasicFileAttributes::fileKey to find this and it should work perfectly. My problem is that I need to develop this with Java 6 and BasicFileAttributes needs Java 7.
Unfortunately it's simply not an option to use Java 7, so does anyone have any suggestions as to an external library that can provide the same functionality?
It was also mentioned that I could do some scripting with Command Prompt (I'm using Windows 7) to try to locate it.
Thanks for any and all help/suggestions.
This is the implementation that I came up with:
public static class FileKey {
private File file;
public FileKey(File file) {
this.file=file;
}
@Override
public int hashCode() {
long res = file.length();
res+=file.lastModified();
if(file.isHidden())
res+=2;
if(file.isDirectory()) {
res+=3;
}
return (int) res;
}
@Override
public boolean equals(Object dst) {
if(dst instanceof FileKey) {
int dstHashCode = ((FileKey) dst).hashCode();
return dstHashCode == this.hashCode();
}
return false;
}
}
Just use that as the fileKey object.