用作记录方便以后查找,用到的工具类:commons-compress
maven依赖
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.4.1</version>
</dependency>
java代码段读取数据:
BufferedInputStream bin = new BufferedInputStream(inputStream);
ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(archive,bin);
ArchiveEntry entry;
while((entry = ais.getNextEntry()) !=null){
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ais));
while((line=bufferedReader.readLine())!=null){
System.out.println(line)
}
}
支持的压缩格式
public static final String AR = "ar";
public static final String CPIO = "cpio";
public static final String DUMP = "dump";
public static final String JAR = "jar";
public static final String TAR = "tar";
public static final String ZIP = "zip";