mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
CompressUtil.createExtractor支持tgz自动识别
This commit is contained in:
parent
1cb0ec327d
commit
c6fc880405
@ -15,6 +15,7 @@
|
||||
* 【poi 】 增加GlobalPoiConfig(issue#IAEHJH@Gitee)
|
||||
* 【core 】 优化IndexedComparator性能(pr#1240@Gitee)
|
||||
* 【http 】 改进ContentType.get忽略空格(pr#3664@Github)
|
||||
* 【http 】 CompressUtil.createExtractor支持tgz自动识别(pr#3674@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复因RFC3986理解有误导致的UrlPath处理冒号转义问题(issue#IAAE88@Gitee)
|
||||
|
@ -170,12 +170,16 @@ public class CompressUtil {
|
||||
if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) {
|
||||
return new SevenZExtractor(file);
|
||||
}
|
||||
try {
|
||||
if (StrUtil.isBlank(archiverName) && file.getName().toLowerCase().endsWith(".tgz")) {
|
||||
|
||||
if(StrUtil.isBlank(archiverName)){
|
||||
final String name = file.getName().toLowerCase();
|
||||
if(name.endsWith(".tgz")){
|
||||
archiverName = "tgz";
|
||||
} else if (StrUtil.isBlank(archiverName) && file.getName().toLowerCase().endsWith(".tar.gz")) {
|
||||
} else if(name.endsWith(".tar.gz")){
|
||||
archiverName = "tar.gz";
|
||||
}
|
||||
}
|
||||
try {
|
||||
return new StreamExtractor(charset, archiverName, file);
|
||||
} catch (CompressException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
|
Loading…
x
Reference in New Issue
Block a user