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.

2
  • 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. Commented Mar 2, 2016 at 1: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. Commented Mar 2, 2016 at 1:21

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.