Created
October 5, 2015 18:26
-
-
Save rhulha/255732567846bf4bef5b to your computer and use it in GitHub Desktop.
Java deepCompare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean deepCompare(Object o1, Object o2) { | |
try { | |
ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); | |
ObjectOutputStream oos1 = new ObjectOutputStream(baos1); | |
oos1.writeObject(o1); | |
oos1.close(); | |
ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); | |
ObjectOutputStream oos2 = new ObjectOutputStream(baos2); | |
oos2.writeObject(o2); | |
oos2.close(); | |
return Arrays.equals(baos1.toByteArray(), baos2.toByteArray()); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment