private boolean isDuplicateFile(String fileName, String path, String backupPath) throws IOException, FileNotFoundException {
File theFile = new File(MEDUtils.addToFilePath(path, fileName));
if (!theFile.exists()) {
throw new FileNotFoundException(MEDUtils.addToFilePath(path, fileName));
}
long fileChecksum = FileUtils.checksumCRC32(theFile);
File[] files = new File(backupPath).listFiles();
long[] checksums = new long[files.length];
for (int i = 0; i < files.length; i++) {
long checksum = FileUtils.checksumCRC32(files[i]);
new MEDInfoEvent(this, "checkForDuplicateFiles()", "File name: " + files[i].getName() + " checksum: [" + checksum + "]");
checksums[i] = checksum;
}
return ArrayUtils.contains(checksums, fileChecksum);
}
Find a Duplicate File...
We had a problem with duplicate XML files showing up to be loaded in an app. After a quick search on the web, the suggestion was to do Checksums. I came up with this:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
No corporate specific info, please...