@Test(expected = RuntimeException.class) public void serializeJson() { JsonObject src = Json.createObjectBuilder() .add("k1", "a") .add("k2", 1) .add("k3", false) .addNull("k") .build(); SerializeUtils.serialize(src); }
public static byte[] serialize(Object obj) { if (obj == null) return null; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream objStream = null; try { objStream = new ObjectOutputStream(byteStream); objStream.writeObject(obj); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { try { objStream.close(); } catch (IOException e) { } } return byteStream.toByteArray(); }
SerializeUtils { public static byte[] serialize(Object obj) { if (obj == null) return null; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream objStream = null; try { objStream = new ObjectOutputStream(byteStream); objStream.writeObject(obj); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { try { objStream.close(); } catch (IOException e) { } } return byteStream.toByteArray(); } }
SerializeUtils { public static byte[] serialize(Object obj) { if (obj == null) return null; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream objStream = null; try { objStream = new ObjectOutputStream(byteStream); objStream.writeObject(obj); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { try { objStream.close(); } catch (IOException e) { } } return byteStream.toByteArray(); }  }
SerializeUtils { public static byte[] serialize(Object obj) { if (obj == null) return null; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream objStream = null; try { objStream = new ObjectOutputStream(byteStream); objStream.writeObject(obj); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { try { objStream.close(); } catch (IOException e) { } } return byteStream.toByteArray(); }  static byte[] serialize(Object obj); static Object deserialize(byte[] bytes); }
SerializeUtils { public static byte[] serialize(Object obj) { if (obj == null) return null; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream objStream = null; try { objStream = new ObjectOutputStream(byteStream); objStream.writeObject(obj); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { try { objStream.close(); } catch (IOException e) { } } return byteStream.toByteArray(); }  static byte[] serialize(Object obj); static Object deserialize(byte[] bytes);  }