0

I have a very old Java application that I am rewriting in .net, I can't change the Java code or the old files in any way.

They have created and stored 10,000+ files that match the format described in this article, a bunch of serialized Java objects.

Question

  • How can I parse these Java objects in c#?
  • Is this even possible?

In the end, if I can read in and serialize the data, I can store it in a more universal format. When I try to deserialize the file I reach an exception, usually telling me the binary format is not valid.

Ajean
  • 5,528
  • 14
  • 46
  • 69
mikefreudiger
  • 11
  • 2
  • 4
  • 2
    Easiest way would be to write the converter program in Java, have it read the files, and write them back out in something C# can understand, preferably something cross-platform like JSON, XML, CSV, ProtocolBuffers ... 10.000 files also sounds like you might consider putting this into a database. – Thilo Mar 02 '16 at 01:21
  • 2
    You'd be better off writing a Java program to load the object graph into memory (using the object definitions from your existing Java code), and then writing them out to a format like XML or (more likely useful) JSON that could be read back in by the .net code. – Jim Garrison Mar 02 '16 at 01:21

1 Answers1

1

A similar question has been asked here.

You have a few options. One is to write a C# class capable of reading objects in Java's serialized format (the one you linked) but this is likely very time consuming. Using C#'s native deserialization algorithm won't work because the format is different (as you've encountered).

An easier alternative is to read the objects from the files using a Java program, and save them as a more universal format such as JSON. (As recommended in an answer to another question here)

Community
  • 1
  • 1