use of com.orion.utils.Objects1 in project orion-kit by lijiahangmax.
the class GzDecompressor method doDecompress.
@Override
public void doDecompress() throws Exception {
OutputStream out = null;
try {
if (decompressInputStream != null) {
this.inputStream = new GzipCompressorInputStream(decompressInputStream);
} else {
this.inputStream = new GzipCompressorInputStream(Files1.openInputStreamFast(decompressFile));
}
String entityName = Optional.ofNullable(inputStream.getMetaData()).map(GzipParameters::getFilename).orElse(null);
if (decompressTargetFileName == null) {
// 配置 > entity > file > objectId
this.decompressTargetFileName = Objects1.def(entityName, Optional.ofNullable(decompressFile).map(File::getName).map(s -> s.substring(0, s.length() - suffix.length() - 1)).orElseGet(ObjectIds::next));
}
if (decompressTargetOutputStream != null) {
out = decompressTargetOutputStream;
} else {
this.decompressTargetFile = new File(decompressTargetPath, decompressTargetFileName);
out = Files1.openOutputStream(decompressTargetFile);
}
Streams.transfer(inputStream, out);
} finally {
Streams.close(inputStream);
if (decompressTargetOutputStream == null) {
Streams.close(out);
}
}
}
Aggregations