Re: Need some help porting from C#

Discussion in 'Java' started by Andy, Jan 16, 2008.

  1. Andy

    Andy Guest

    On Jan 16, 2:38 pm, Andy <> wrote:
    > HI,
    >
    > I'm trying to port some code from C# to Java. The C# code uses a <a
    > href="http://msdn2.microsoft.com/en-us/library/
    > system.runtime.serialization.formatters.binary.binaryformatter(VS.
    > 85).aspx">BinaryFormatter</a> class to serialize the object or graph
    > to a binary representation. What would be the class equivalent in
    > Java?
    >
    > Thanks
    > Andy


    Opps... google didn't like my html.. the C# class is BinaryFormatter.
    Documentation can be found here:
    http://msdn2.microsoft.com/en-us/li...formatters.binary.binaryformatter(VS.85).aspx
     
    Andy, Jan 16, 2008
    #1
    1. Advertising

  2. Andy

    rossum Guest

    On Wed, 16 Jan 2008 11:39:31 -0800 (PST), Andy <>
    wrote:

    >On Jan 16, 2:38 pm, Andy <> wrote:
    >> HI,
    >>
    >> I'm trying to port some code from C# to Java. The C# code uses a <a
    >> href="http://msdn2.microsoft.com/en-us/library/
    >> system.runtime.serialization.formatters.binary.binaryformatter(VS.
    >> 85).aspx">BinaryFormatter</a> class to serialize the object or graph
    >> to a binary representation. What would be the class equivalent in
    >> Java?
    >>
    >> Thanks
    >> Andy

    >
    >Opps... google didn't like my html.. the C# class is BinaryFormatter.
    >Documentation can be found here:
    >http://msdn2.microsoft.com/en-us/li...formatters.binary.binaryformatter(VS.85).aspx


    Reading the MS documentation: "Serializes and deserializes an object,
    or an entire graph of connected objects, in binary format."

    This looks a lot like Java Serialization:
    http://java.sun.com/developer/technicalArticles/Programming/serialization/

    rossum
     
    rossum, Jan 16, 2008
    #2
    1. Advertising

  3. Andy

    Lew Guest

    Lew, Jan 17, 2008
    #3
  4. Andy

    Andy Guest

    On Jan 16, 3:27 pm, rossum <> wrote:
    > On Wed, 16 Jan 2008 11:39:31 -0800 (PST), Andy <>
    > wrote:
    >
    >
    >
    >
    >
    > >On Jan 16, 2:38 pm, Andy <> wrote:
    > >> HI,

    >
    > >> I'm trying to port some code from C# to Java.  The C# code uses a <a
    > >> href="http://msdn2.microsoft.com/en-us/library/
    > >> system.runtime.serialization.formatters.binary.binaryformatter(VS.
    > >> 85).aspx">BinaryFormatter</a> class to serialize the object or graph
    > >> to a binary representation.  What would be the class equivalent in
    > >> Java?

    >
    > >> Thanks
    > >> Andy

    >
    > >Opps... google didn't like my html.. the C# class is BinaryFormatter.
    > >Documentation can be found here:
    > >http://msdn2.microsoft.com/en-us/library/system.runtime.serialization...

    >
    > Reading the MS documentation: "Serializes and deserializes an object,
    > or an entire graph of connected objects, in binary format."
    >
    > This looks a lot like Java Serialization:http://java.sun.com/developer/technicalArticles/Programming/serializa...
    >
    > rossum- Hide quoted text -
    >
    > - Show quoted text -


    Ok, so simply implementing the interface is fine.. no code needs to be
    written, Java will handle finding the fields and restoring them?

    Sounds great, thanks!
     
    Andy, Jan 25, 2008
    #4
  5. Andy

    Lew Guest

    Andy wrote:
    > Ok, so simply implementing the [java.io.Serializable] interface is fine.. no code needs to be
    > written, Java will handle finding the fields and restoring them?


    Not true. Implementing Serializable naively will appear to work, at first,
    but can cause major performance hits and kill future maintainability.

    Read the chapters in Joshua Bloch's seminal book, /Effective Java/, that
    pertain to serialization. There are a host of pitfalls, and likely some
    methods and members that you will need to write, that is, if you want your
    code to go into production. And survive there.

    --
    Lew
     
    Lew, Jan 25, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    0
    Views:
    701
    Guest
    Feb 25, 2004
  2. Andy
    Replies:
    2
    Views:
    293
    Arne Vajhøj
    Jan 17, 2008
  3. jpw
    Replies:
    1
    Views:
    381
    Gabriel Genellina
    Feb 5, 2008
  4. Frank Steinmetzger
    Replies:
    2
    Views:
    365
    Frank Steinmetzger
    Mar 29, 2008
  5. kj
    Replies:
    10
    Views:
    472
Loading...

Share This Page