On Dec 2, 9:57 am, Tayssir John Gabbour <[EMAIL PROTECTED]>
wrote:
> (defn my-identity "Copies obj through serialization and
> deserialization."
>   [obj]
>   (let [byte-out (new java.io.ByteArrayOutputStream)
>         obj-out  (new java.io.ObjectOutputStream byte-out)]
>     (try (.writeObject obj-out obj)
>          (finally (.close obj-out)))
>     (let [obj-in  (new java.io.ObjectInputStream
>                        (new java.io.ByteArrayInputStream (.toByteArray
> byte-out)))]
>       (try (.readObject obj-in)
>            (finally (.close obj-in))))))

BTW, sorry for the absurd code; I should .close() byte-out instead of
obj-out.

And I'll have to figure out how to readably close a stream in a
finally clause.


Tayssir

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to