[repost ]Java Serializable Object to Byte Array
original:http://stackoverflow.com/questions/2836646/java-serializable-object-to-byte-array Prepare bytes to send: ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(bos); out.writeObject(yourObject); byte[] yourBytes = bos.toByteArray(); ... } finally { try { if (out != null) { out.close(); } } catch (IOException ex) { // ignore close exception } try { bos.close(); } catch (IOException ex) [...]
via WordPress http://blog.newitfarmer.com/java/others-java/13623/repost-java-serializable-object-to-byte-array#utm_source=rss&utm_medium=rss&utm_campaign=repost-java-serializable-object-to-byte-array
via WordPress http://blog.newitfarmer.com/java/others-java/13623/repost-java-serializable-object-to-byte-array#utm_source=rss&utm_medium=rss&utm_campaign=repost-java-serializable-object-to-byte-array
Labels: hanhuiwen
0 Comments:
Post a Comment
<< Home