3

I have a dump after java.util.zip.Deflater (can confirm it's valid because Java's Inflater opens it fine) and need to open it in .NET:

byte[] content = ReadSample(sampleName);
var input = new MemoryStream(content);
var output = new MemoryStream();

using (var z = new System.IO.Compression.DeflateStream(input, CompressionMode.Decompress, true))
        z.CopyTo(output);

This throws

System.IO.InvalidDataException : Block length does not match with its complement.

Tried Ionic.Zlib.DeflateStream - similar exception. How can i do that?

The dump starts with 97 86 E8 92 47 3D 40 EA (if that matters).

Update: Unfortunately, i have no control over Java party as the system is in production.

UserControl
  • 14,181
  • 19
  • 92
  • 181

3 Answers3

1

To resolve platform dependent copression and decompression use

Approach-1

In .NET you can use System.IO.Compression.GZipStream

In Java use java.util.zip.GZIPOutPutStream

Approach-2

You can also use 7-zip. There is an SDK for both c# and Java.

Sunil Kumar Sahoo
  • 51,611
  • 53
  • 174
  • 242
  • I had luck using Ionic.Zlib.GZipStream for compression in c# and then GZIPInputStream in Java for decompression. Thanks for your suggestion :) – Mazrick Sep 16 '14 at 20:41
1

Since you have no control over the Java output, how about integrating some J# in your .NET app in order to use java.util.zip.Inflater directly? See this MSDN article.

This similar question might also be helpful, particularly the suggestion of #zipLib.

Community
  • 1
  • 1
Esoteric Screen Name
  • 5,994
  • 4
  • 28
  • 38
0

I don't believe Deflater and Inflater are standard formats and I would be surprised if it were the same in Java and C#.

I would suggest you use a standard format such as GZIP which should be the same across platforms.

Peter Lawrey
  • 513,304
  • 74
  • 731
  • 1,106
  • -1 The whole point of Deflater/Inflater (in Java or C#) is to provide high level API for the zlib library which also implements GZIP. – Sulthan May 21 '13 at 09:19