I have a task that converts a fingerprint template into byte array (serialize). then I compared the two byte arrays before converting it into blob and after converting it back from byte arrray to blob. they’re giving me different results when i print them.
here’s the code
`Blob blob = con.createBlob();
blob.setBytes(1, enroller.getTemplate().serialize());
System.out.println(enroller.getTemplate().serialize());
//prints [B@53de73a3
int blobLength = (int) blob.length();
byte[] blobAsBytes = blob.getBytes(1, blobLength);
System.out.println(blobAsBytes);
//prints [B@3179fd59`
any ideas?
Edit: I also tried using array.equals() and it gave me a false output.
Why would you expect these to be the same ? You’re printing using the
toString()method on a byte array, and that’s going to give you the type info + a number related to (but not necessarily) the memory location (it’s actually thehashCode()whentoString()is not overridden).If you want to compare these, then use
equals()on the two byte arrays. Or perhaps compare the elements one-by-one (check the length first to avoid an unnecessary traversal if the sizes don’t match)