当前位置: 首页 > news >正文

Google Archive Patch 基础应用代码记录

项目地址

Google Archive Patch

前置

<!-- 差量应用模块 -->
<dependency><groupId>com.google.archivepatcher</groupId><artifactId>archive-patch-applier</artifactId><version>1.0.4</version><scope>test</scope>
</dependency>
<!-- 差量生成模块 --><dependency><groupId>com.google.archivepatcher</groupId><artifactId>archive-patch-generator</artifactId><version>1.0.4</version>
</dependency>
<!-- applier与generator的公共模块 -->
<dependency><groupId>com.google.archivepatcher</groupId><artifactId>archive-patch-shared</artifactId><version>1.0.4</version>
</dependency>

生成补丁

import com.google.archivepatcher.generator.FileByFileV1DeltaGenerator;
import com.google.archivepatcher.shared.DefaultDeflateCompatibilityWindow;
import java.io.File;
import java.io.FileOutputStream;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;/** Generate a patch; args are old file path, new file path, and patch file path. */
public class SamplePatchGenerator {public static void main(String... args) throws Exception {if (!new DefaultDeflateCompatibilityWindow().isCompatible()) {System.err.println("zlib not compatible on this system");System.exit(-1);}File oldFile = new File(args[0]); // must be a zip archiveFile newFile = new File(args[1]); // must be a zip archiveDeflater compressor = new Deflater(9, true); // to compress the patchtry (FileOutputStream patchOut = new FileOutputStream(args[2]); // args[2]为补丁存放地址DeflaterOutputStream compressedPatchOut =new DeflaterOutputStream(patchOut, compressor, 32768)) {new FileByFileV1DeltaGenerator().generateDelta(oldFile, newFile, compressedPatchOut);compressedPatchOut.finish();compressedPatchOut.flush();} finally {compressor.end();}}
}

应用补丁

import com.google.archivepatcher.applier.FileByFileV1DeltaApplier;
import com.google.archivepatcher.shared.DefaultDeflateCompatibilityWindow;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;/** Apply a patch; args are old file path, patch file path, and new file path. */
public class SamplePatchApplier {public static void main(String... args) throws Exception {if (!new DefaultDeflateCompatibilityWindow().isCompatible()) {System.err.println("zlib not compatible on this system");System.exit(-1);}File oldFile = new File(args[0]); // must be a zip archive args[0]为旧版本文件地址Inflater uncompressor = new Inflater(true); // to uncompress the patchtry (FileInputStream compressedPatchIn = new FileInputStream(args[1]); // args[1]补丁文件地址InflaterInputStream patchIn =new InflaterInputStream(compressedPatchIn, uncompressor, 32768);FileOutputStream newFileOut = new FileOutputStream(args[2])) { // args[2]合成文件地址new FileByFileV1DeltaApplier().applyDelta(oldFile, patchIn, newFileOut);} finally {uncompressor.end();}}
}
http://www.lryc.cn/news/212351.html

相关文章:

  • 机器学习——代价敏感错误率与代价曲线
  • 如何利用 ChatGPT 提升编程技能
  • ChatGPT:@EqualsAndHashCode(callSuper = false)是什么意思
  • docker部署的mariadb忘记密码
  • 一体化模型图像去雨+图像去噪+图像去模糊(图像处理-图像复原-代码+部署运行教程)
  • [java/力扣110]平衡二叉树——优化前后的两种方法
  • 吉他、班卓琴和贝斯吉他降分器:Arobas Music Guitar 8.1.1
  • cocos tilemap的setTileGIDAt方法不实时更新
  • 机器学习---使用 TensorFlow 构建神经网络模型预测波士顿房价和鸢尾花数据集分类
  • 铁合金电炉功率因数补偿装置设计
  • 表格识别软件:科技革新引领行业先锋,颠覆性发展前景广阔
  • 【Redis】高并发分布式结构服务器
  • 微信小程序拍照页面自定义demo
  • 单目标应用:进化场优化算法(Evolutionary Field Optimization,EFO)求解微电网优化MATLAB
  • 推荐算法面试
  • 长图切图怎么切
  • 动手学深度学习 - 学习环境配置
  • 洛谷 B2004 对齐输出 C++代码
  • seccomp学习 (1)
  • Linux指令【上】
  • RK3568-clock
  • 新恶意软件使用 MSIX 软件包来感染 Windows
  • 干货!数字IC后端入门学习笔记
  • 力扣:144. 二叉树的前序遍历(Python3)
  • 【数据挖掘 | 数据预处理】缺失值处理 重复值处理 文本处理 确定不来看看?
  • 二叉树问题——前/中/后/层遍历(递归与栈)
  • Nor Flash和Nand Flash的区别——笔记
  • 7+共病思路。WGCNA+多机器学习+实验简单验证,易操作
  • 开发者看亚马逊云科技1024【文末有福利~】
  • 操作系统(Linux)外壳程序shell 、用户、权限