Serializes and then deserializes the given instance - should be not null. @param orgig this instance is serialized and then deserialized @return the instance after serialization and deserialization
(final T orgig)
| 47 | * @return the instance after serialization and deserialization |
| 48 | */ |
| 49 | @SuppressWarnings({"unchecked"}) |
| 50 | public static <T extends Serializable> T serDeser(final T orgig) { |
| 51 | try { |
| 52 | final ByteArrayOutputStream byteOS = new ByteArrayOutputStream(); |
| 53 | new ObjectOutputStream(byteOS).writeObject(orgig); |
| 54 | return (T) new ObjectInputStream(new ByteArrayInputStream(byteOS.toByteArray())).readObject(); |
| 55 | } catch (Exception e) { |
| 56 | throw new RuntimeException(e); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | |
| 61 | static void cleanUp() { |
no test coverage detected