List of utility methods to do Zip Byte Array
byte[] | zipByte(byte[] data) zip Byte Deflater compresser = new Deflater(); compresser.reset(); compresser.setInput(data); compresser.finish(); byte result[] = new byte[0]; ByteArrayOutputStream o = new ByteArrayOutputStream(1); try { byte[] buf = new byte[CacheSize]; ... |
boolean | zip(byte[] data, String fileName, String path) zip String TAG = "ZipUtil : "; File pathFile = new File(path); pathFile.mkdirs(); String zipName = path + "\\" + fileName + ".zip"; File file = new File(zipName); if (!file.exists()) { file.createNewFile(); FileOutputStream os = null; ZipOutputStream out = null; try { os = new FileOutputStream(file); out = new ZipOutputStream(os); String tmp = new String(fileName.getBytes("UTF-8")); tmp = unicodeEscape(tmp); ZipEntry entry = new ZipEntry(tmp + ".xml"); out.putNextEntry(entry); out.write(data); out.flush(); out.closeEntry(); out.flush(); out.finish(); } catch (Exception e) { e.printStackTrace(); System.err.println(TAG + " Error " + e.toString()); throw e; } finally { out.close(); os.close(); return true; |