Compare two file binaries in Mendix (or Java action)

0
I'm trying to create a method to compare two files. One that's already in the database and one that's uploaded by the current user. I need a way to compare them but not their size, I want to compare their binary information. So now I'm trying with a java action:                   OutputStream outputStreamOldDocument = new ByteArrayOutputStream();         OutputStream outputStreamNewDocument = new ByteArrayOutputStream();         this.OldDocument.getContents( getContext(), outputStreamOldDocument);         this.NewDocument.getContents(getContext(), outputStreamNewDocument); if (!outputStreamNewDocument.equals(outputStreamOldDocument) {             return true;         }         else {              return false;         } this always returns false Any ideas?
asked
1 answers
0

See https://stackoverflow.com/questions/22818590/java-how-to-check-that-2-binary-files-are-same .

As this thread nicely points out, depending on the expected usage pattern of your logic, you might consider storing an md5 hash, and compare hashes as this would save you from having to retrieve the stored file form disk.

answered