This commit is contained in:
Looly 2023-07-18 00:02:30 +08:00
parent 9fec53f8f2
commit 2495825c74

View File

@ -91,22 +91,22 @@ public class StreamArchiver implements Archiver {
* @param targetStream 归档输出的流 * @param targetStream 归档输出的流
*/ */
public StreamArchiver(final Charset charset, final String archiverName, final OutputStream targetStream) { public StreamArchiver(final Charset charset, final String archiverName, final OutputStream targetStream) {
if("tgz".equalsIgnoreCase(archiverName) || "tar.gz".equalsIgnoreCase(archiverName)){ if ("tgz".equalsIgnoreCase(archiverName) || "tar.gz".equalsIgnoreCase(archiverName)) {
//issue#I5J33E支持tgz格式解压 //issue#I5J33E支持tgz格式解压
try { try {
this.out = new TarArchiveOutputStream(new GzipCompressorOutputStream(targetStream)); this.out = new TarArchiveOutputStream(new GzipCompressorOutputStream(targetStream));
} catch (final IOException e) { } catch (final IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
return; } else {
final ArchiveStreamFactory factory = new ArchiveStreamFactory(charset.name());
try {
this.out = factory.createArchiveOutputStream(archiverName, targetStream);
} catch (final ArchiveException e) {
throw new CompressException(e);
}
} }
final ArchiveStreamFactory factory = new ArchiveStreamFactory(charset.name());
try {
this.out = factory.createArchiveOutputStream(archiverName, targetStream);
} catch (final ArchiveException e) {
throw new CompressException(e);
}
//特殊设置 //特殊设置
if (this.out instanceof TarArchiveOutputStream) { if (this.out instanceof TarArchiveOutputStream) {