does anyone know how can I achieve java's Deflater.deflate() functionality in .NET so it would be understandable for java's Infalter.inflate() method?
regards, Rafal
ZlibStream class inside DotNetZip package (https://dotnetzip.codeplex.com/) is equivalent to java.util.zip.deflater.
Nuget: Install-Package DotNetZip
usage for byte array:
ZlibStream.CompressBuffer(dataBytesArray);
ZlibStream.UncompressBuffer(dataBytesArray);
it also has String compression and decompression, and the class can be used with streams exactly the same way as .NET DefalteStream. Please note that DeflateStream of DotNetZip is not the same as its Java, ZlibStream is.
Additional Info: DeflateStream of .NET is not compatible with Deflate in Java. In fact, Java uses Zlib and adds 2-6 bytes header and 4 bytes checksum by default. Cutting off the bytes (suggested by some articles like http://blogs.msdn.com/b/bclteam/archive/2007/05/16/system-io-compression-capabilities-kim-hamilton.aspx) will work, but I don't suggest it as parsing header length may cause bugs.
I don't suggest SharpZipLib as it is pure C# and usually performance is important working with compression and decompression data. Look at http://www.codeproject.com/Articles/434583/SharpZipLib-or-DotNetZip-Which-should-you-use
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With