From 6b4e5bfbe07b11d88d99bb6ba5490e529ebd819e Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 16 Apr 2017 00:40:58 +0800 Subject: [PATCH] equalsFileContent --- source/net/filebot/util/FileUtilities.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index ee4a855e..36b0e202 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -274,6 +274,27 @@ public final class FileUtilities { return a.getPath().equals(b.getPath()); } + public static boolean equalsFileContent(File a, File b) { + // must have the same file size + if (a.length() != b.length()) { + return false; + } + + // must not be a folder + if (a.isDirectory() || b.isDirectory()) { + return false; + } + + // must be equal byte by byte + try { + return FileUtils.contentEquals(a, b); + } catch (Exception e) { + log.warning(cause(e)); + } + + return false; + } + /** * Pattern used for matching file extensions. *