添加maven
<!--jbsdiff--> <dependency> <groupId>io.sigpipe</groupId> <artifactId>jbsdiff</artifactId> <version>1.0</version> </dependency>
工具类
package cn.stylefeng.guns.core.util; import io.sigpipe.jbsdiff.Diff; import io.sigpipe.jbsdiff.InvalidHeaderException; import org.apache.commons.compress.compressors.CompressorException; import java.io.*; public class ByteUtil { /** * 获得指定文件的byte数组 */ public static byte[] getBytes(String filePath){ byte[] buffer = null; try { File file = new File(filePath); FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); byte[] b = new byte[1024]; int n; while ((n = fis.read(b)) != -1