/**
* @功能描述 压缩tar.gz 文件
* @param sources 源文件集合
* @param outPath 目标文件名称 无后缀的 例子 G:\backup\logstash-2020.04.22
* @return 返回压缩结果
* @throws Exception*/
public static voidpacket(String[] sources, String outPath) throws Exception {//gz文件 名称 TAR GZ 就是 .tar.gz
String gzPath = String.format("%s%s%s",outPath, TAR, GZ);
ByteArrayOutputStream byteArrayOutputStream= newByteArrayOutputStream();
TarArchiveOutputStream tarArchiveOutputStream= null;
GZIPOutputStream gzipOutputStream= null;try{
tarArchiveOutputStream= newTarArchiveOutputStream(byteArrayOutputStream);//将所有文件打包成 tar文件
try{for(String source : sources) {
File file= newFile(source);
tarArchiveOutputStream.putArchiveEntry(newTarArchiveEntry(file, file.getName()));
IOUtils.copy(newFileInputStream(file), tarArc