Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
First add vjslib.dll from add reference link. Through this dll, we can compress data compatible with Java Compression.
Add Namespace into your class
using
/// <summary> /// This function is used to compress byte array data using java util. /// </summary> /// <param name="data">Byte Array Data</param> /// <param name="path">Path to Store compress File</param> /// <param name="fileName">File Name</param> public static void compressFileWrite(byte[] data, String path, String fileName) { try { java.io.File folder = new java.io.File(path + FORWARD_SLASH + ENCRYPT_OUTPUT_PATH); if (!folder.isDirectory()) { folder.mkdir(); } java.io.File file = new java.io.File(folder.getPath() + FORWARD_SLASH + fileName); FileOutputStream fos = new FileOutputStream(file); DeflaterOutputStream dos = new DeflaterOutputStream(fos); dos.write((sbyte[])(Array)data); dos.close(); } catch (java.io.FileNotFoundException Ex) { throw new Exception("Error while reading file \n" + Ex.Message); } catch (java.io.IOException Ex) { throw new Exception("Error in Compress File \n" + Ex.Message); } }
This above code is compatible with java compression