MCPcopy Create free account
hub / github.com/beanshell/beanshell / serDeser

Method serDeser

tests/junitTests/src/bsh/TestUtil.java:49–58  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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() {

Calls 3

writeObjectMethod · 0.80
readObjectMethod · 0.80
toByteArrayMethod · 0.80

Tested by

no test coverage detected