This is Argyn's blog. I comment on topics of my interests such as software, math, finance, and music. Also, I write about local events in Northern Virginia, USA and all things related to Kazakhstan

Monday, May 04, 2009

How to read .NET binary object files from Java

I had to read .NET binary files, which were written with BinaryWriter class Write method. This is similar to Java's object output stream class. However, you can't read these files with Java's ObjectInputStream.

The way to read the binary outputs is through low level byte reading and converting those bytes into Java objects. There's standard methods to convert bytes into Java's primitive types, but you have to first alighn bytes in a proper order. This post is about converting byte arrays into Java numeric types. You can use those methods. One trick with .NET binaries is that all bytes come in little-endian format. Also, String's have their lengths in the first byte.

No comments: