This commit is contained in:
@@ -58,8 +58,8 @@ public enum CompressType {
|
||||
* @return 压缩操作对象
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public Compressor<?> ofCompress(String fromPath) throws Exception {
|
||||
return getCompressor().from(fromPath);
|
||||
public Compressor<?> compressFrom(String fromPath) throws Exception {
|
||||
return getCompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ public enum CompressType {
|
||||
* @return 压缩操作对象
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public Compressor<?> ofCompress(File fromFile) throws Exception {
|
||||
return getCompressor().from(fromFile);
|
||||
public Compressor<?> compressFrom(File fromFile) throws Exception {
|
||||
return getCompressor().of(fromFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,8 +90,8 @@ public enum CompressType {
|
||||
* @return 解压操作对象
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public Decompressor<?> ofCompressed(File fromFile) throws Exception {
|
||||
return getDecompressor().from(fromFile);
|
||||
public Decompressor<?> decompressedFrom(File fromFile) throws Exception {
|
||||
return getDecompressor().of(fromFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,8 +101,8 @@ public enum CompressType {
|
||||
* @return 解压操作对象
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public Decompressor<?> ofCompressed(InputStream fromStream) throws Exception {
|
||||
return getDecompressor().from(fromStream);
|
||||
public Decompressor<?> decompressedFrom(InputStream fromStream) throws Exception {
|
||||
return getDecompressor().of(fromStream);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ public enum CompressType {
|
||||
* @throws UnsupportedOperationException 不支持的文件
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public static Decompressor<?> fromFile(File file) throws Exception {
|
||||
public static Decompressor<?> from(File file) throws Exception {
|
||||
try (InputStream inputStream = IO.getInputStream(file)) {
|
||||
byte[] head = new byte[512];
|
||||
int length = inputStream.read(head);
|
||||
@@ -122,16 +122,16 @@ public enum CompressType {
|
||||
throw new UnsupportedOperationException("empty file");
|
||||
}
|
||||
if (SevenZFile.matches(head, length)) {
|
||||
return Z7.ofCompressed(file);
|
||||
return Z7.decompressedFrom(file);
|
||||
}
|
||||
if (ZipArchiveInputStream.matches(head, length)) {
|
||||
return ZIP.ofCompressed(file);
|
||||
return ZIP.decompressedFrom(file);
|
||||
}
|
||||
if (GzipCompressorInputStream.matches(head, length)) {
|
||||
return GZIP.ofCompressed(file);
|
||||
return GZIP.decompressedFrom(file);
|
||||
}
|
||||
if (TarArchiveInputStream.matches(head, length)) {
|
||||
return TAR.ofCompressed(file);
|
||||
return TAR.decompressedFrom(file);
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException("not support file");
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class Compressor<T extends Compressor<T>> extends AbstractRunner
|
||||
* @param fromPath 源路径
|
||||
* @return 当前压缩器
|
||||
*/
|
||||
public T from(String fromPath) {
|
||||
protected T of(String fromPath) {
|
||||
TimiException.required(fromPath, "not found fromPath");
|
||||
this.fromPath = fromPath;
|
||||
return self();
|
||||
@@ -36,9 +36,9 @@ public abstract class Compressor<T extends Compressor<T>> extends AbstractRunner
|
||||
* @param fromFile 源文件
|
||||
* @return 当前压缩器
|
||||
*/
|
||||
public T from(File fromFile) {
|
||||
protected T of(File fromFile) {
|
||||
TimiException.required(fromFile, "not found fromFile");
|
||||
return from(fromFile.getAbsolutePath());
|
||||
return of(fromFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class Decompressor<T extends Decompressor<T>> extends AbstractRu
|
||||
* @param fromFile 源压缩文件
|
||||
* @return 当前解压器
|
||||
*/
|
||||
public T from(File fromFile) {
|
||||
protected T of(File fromFile) {
|
||||
TimiException.required(fromFile, "not found fromFile");
|
||||
this.fromFile = fromFile;
|
||||
this.fromStream = null;
|
||||
@@ -40,9 +40,9 @@ public abstract class Decompressor<T extends Decompressor<T>> extends AbstractRu
|
||||
* @param fromPath 源压缩文件路径
|
||||
* @return 当前解压器
|
||||
*/
|
||||
public T from(String fromPath) {
|
||||
protected T of(String fromPath) {
|
||||
TimiException.required(fromPath, "not found fromPath");
|
||||
return from(new File(fromPath));
|
||||
return of(new File(fromPath));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public abstract class Decompressor<T extends Decompressor<T>> extends AbstractRu
|
||||
* @param fromStream 源压缩输入流
|
||||
* @return 当前解压器
|
||||
*/
|
||||
public T from(InputStream fromStream) {
|
||||
public T of(InputStream fromStream) {
|
||||
TimiException.required(fromStream, "not found fromStream");
|
||||
this.fromStream = fromStream;
|
||||
this.fromFile = null;
|
||||
|
||||
@@ -26,8 +26,8 @@ public class GZipCompressor extends Compressor<GZipCompressor> {
|
||||
* @param fromPath 源路径
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static GZipCompressor of(String fromPath) {
|
||||
return new GZipCompressor().from(fromPath);
|
||||
public static GZipCompressor from(String fromPath) {
|
||||
return new GZipCompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,8 +36,8 @@ public class GZipCompressor extends Compressor<GZipCompressor> {
|
||||
* @param fromFile 源文件
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static GZipCompressor of(File fromFile) {
|
||||
return new GZipCompressor().from(fromFile);
|
||||
public static GZipCompressor from(File fromFile) {
|
||||
return new GZipCompressor().of(fromFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,8 @@ public class GZipDecompressor extends Decompressor<GZipDecompressor> {
|
||||
* @param fromFile 源压缩文件
|
||||
* @return 解压器
|
||||
*/
|
||||
public static GZipDecompressor of(File fromFile) {
|
||||
return new GZipDecompressor().from(fromFile);
|
||||
public static GZipDecompressor from(File fromFile) {
|
||||
return new GZipDecompressor().of(fromFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,8 +33,8 @@ public class GZipDecompressor extends Decompressor<GZipDecompressor> {
|
||||
* @param fromPath 源压缩文件路径
|
||||
* @return 解压器
|
||||
*/
|
||||
public static GZipDecompressor of(String fromPath) {
|
||||
return new GZipDecompressor().from(fromPath);
|
||||
public static GZipDecompressor from(String fromPath) {
|
||||
return new GZipDecompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,8 +43,8 @@ public class GZipDecompressor extends Decompressor<GZipDecompressor> {
|
||||
* @param fromStream 源压缩输入流
|
||||
* @return 解压器
|
||||
*/
|
||||
public static GZipDecompressor of(InputStream fromStream) {
|
||||
return new GZipDecompressor().from(fromStream);
|
||||
public static GZipDecompressor from(InputStream fromStream) {
|
||||
return new GZipDecompressor().of(fromStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,8 +24,8 @@ public class TarCompressor extends Compressor<TarCompressor> {
|
||||
* @param fromPath 源路径
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static TarCompressor of(String fromPath) {
|
||||
return new TarCompressor().from(fromPath);
|
||||
public static TarCompressor from(String fromPath) {
|
||||
return new TarCompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ public class TarCompressor extends Compressor<TarCompressor> {
|
||||
* @param fromFile 源文件
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static TarCompressor of(File fromFile) {
|
||||
return new TarCompressor().from(fromFile);
|
||||
public static TarCompressor from(File fromFile) {
|
||||
return new TarCompressor().of(fromFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,8 +22,8 @@ public class TarDecompressor extends Decompressor<TarDecompressor> {
|
||||
* @param fromFile 源压缩文件
|
||||
* @return 解压器
|
||||
*/
|
||||
public static TarDecompressor of(File fromFile) {
|
||||
return new TarDecompressor().from(fromFile);
|
||||
public static TarDecompressor from(File fromFile) {
|
||||
return new TarDecompressor().of(fromFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,8 +32,8 @@ public class TarDecompressor extends Decompressor<TarDecompressor> {
|
||||
* @param fromPath 源压缩文件路径
|
||||
* @return 解压器
|
||||
*/
|
||||
public static TarDecompressor of(String fromPath) {
|
||||
return new TarDecompressor().from(fromPath);
|
||||
public static TarDecompressor from(String fromPath) {
|
||||
return new TarDecompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,8 @@ public class TarDecompressor extends Decompressor<TarDecompressor> {
|
||||
* @param fromStream 源压缩输入流
|
||||
* @return 解压器
|
||||
*/
|
||||
public static TarDecompressor of(InputStream fromStream) {
|
||||
return new TarDecompressor().from(fromStream);
|
||||
public static TarDecompressor from(InputStream fromStream) {
|
||||
return new TarDecompressor().of(fromStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,8 +25,8 @@ public class Z7Compressor extends Compressor<Z7Compressor> {
|
||||
* @param fromPath 源路径
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static Z7Compressor of(String fromPath) {
|
||||
return new Z7Compressor().from(fromPath);
|
||||
public static Z7Compressor from(String fromPath) {
|
||||
return new Z7Compressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,15 +35,15 @@ public class Z7Compressor extends Compressor<Z7Compressor> {
|
||||
* @param fromFile 源文件
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static Z7Compressor of(File fromFile) {
|
||||
return new Z7Compressor().from(fromFile);
|
||||
public static Z7Compressor from(File fromFile) {
|
||||
return new Z7Compressor().of(fromFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void toStream(String fromPath, OutputStream toStream) throws Exception {
|
||||
Path tempFile = Files.createTempFile("timi-compress-", ".7z");
|
||||
try {
|
||||
from(fromPath).toFile(tempFile.toFile());
|
||||
of(fromPath).toFile(tempFile.toFile());
|
||||
try (InputStream inputStream = Files.newInputStream(tempFile)) {
|
||||
transfer(inputStream, toStream, false);
|
||||
toStream.flush();
|
||||
|
||||
@@ -24,8 +24,8 @@ public class Z7Decompressor extends Decompressor<Z7Decompressor> {
|
||||
* @param fromFile 源压缩文件
|
||||
* @return 解压器
|
||||
*/
|
||||
public static Z7Decompressor of(File fromFile) {
|
||||
return new Z7Decompressor().from(fromFile);
|
||||
public static Z7Decompressor from(File fromFile) {
|
||||
return new Z7Decompressor().of(fromFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ public class Z7Decompressor extends Decompressor<Z7Decompressor> {
|
||||
* @param fromPath 源压缩文件路径
|
||||
* @return 解压器
|
||||
*/
|
||||
public static Z7Decompressor of(String fromPath) {
|
||||
return new Z7Decompressor().from(fromPath);
|
||||
public static Z7Decompressor from(String fromPath) {
|
||||
return new Z7Decompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,8 +44,8 @@ public class Z7Decompressor extends Decompressor<Z7Decompressor> {
|
||||
* @param fromStream 源压缩输入流
|
||||
* @return 解压器
|
||||
*/
|
||||
public static Z7Decompressor of(InputStream fromStream) {
|
||||
return new Z7Decompressor().from(fromStream);
|
||||
public static Z7Decompressor from(InputStream fromStream) {
|
||||
return new Z7Decompressor().of(fromStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,8 +24,8 @@ public class ZipCompressor extends Compressor<ZipCompressor> {
|
||||
* @param fromPath 源路径
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static ZipCompressor of(String fromPath) {
|
||||
return new ZipCompressor().from(fromPath);
|
||||
public static ZipCompressor from(String fromPath) {
|
||||
return new ZipCompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ public class ZipCompressor extends Compressor<ZipCompressor> {
|
||||
* @param fromFile 源文件
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static ZipCompressor of(File fromFile) {
|
||||
return new ZipCompressor().from(fromFile);
|
||||
public static ZipCompressor from(File fromFile) {
|
||||
return new ZipCompressor().of(fromFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,8 +24,8 @@ public class ZipDecompressor extends Decompressor<ZipDecompressor> {
|
||||
* @param fromFile 源压缩文件
|
||||
* @return 解压器
|
||||
*/
|
||||
public static ZipDecompressor of(File fromFile) {
|
||||
return new ZipDecompressor().from(fromFile);
|
||||
public static ZipDecompressor from(File fromFile) {
|
||||
return new ZipDecompressor().of(fromFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ public class ZipDecompressor extends Decompressor<ZipDecompressor> {
|
||||
* @param fromPath 源压缩文件路径
|
||||
* @return 解压器
|
||||
*/
|
||||
public static ZipDecompressor of(String fromPath) {
|
||||
return new ZipDecompressor().from(fromPath);
|
||||
public static ZipDecompressor from(String fromPath) {
|
||||
return new ZipDecompressor().of(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,8 +44,8 @@ public class ZipDecompressor extends Decompressor<ZipDecompressor> {
|
||||
* @param fromStream 源压缩输入流
|
||||
* @return 解压器
|
||||
*/
|
||||
public static ZipDecompressor of(InputStream fromStream) {
|
||||
return new ZipDecompressor().from(fromStream);
|
||||
public static ZipDecompressor from(InputStream fromStream) {
|
||||
return new ZipDecompressor().of(fromStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GzipTest {
|
||||
|
||||
@Test
|
||||
public void testStaticCompress() throws Exception {
|
||||
GZipCompressor compressor = GZipCompressor.of("testSrc").toFile("testOut/test.gz");
|
||||
GZipCompressor compressor = GZipCompressor.from("testSrc").toFile("testOut/test.gz");
|
||||
Assertions.assertNotNull(compressor);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GzipTest {
|
||||
File out = IO.file("testOut/test-chain.gz");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
GZipCompressor compressor = GZipCompressor.of("testSrc");
|
||||
GZipCompressor compressor = GZipCompressor.from("testSrc");
|
||||
Assertions.assertSame(
|
||||
compressor,
|
||||
compressor
|
||||
@@ -46,15 +46,15 @@ public class GzipTest {
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.gz");
|
||||
GZipCompressor.of("testSrc").toFile(in);
|
||||
GZipCompressor.from("testSrc").toFile(in);
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).toPath(out.getAbsolutePath());
|
||||
CompressType.from(in).toPath(out.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressToStream() throws Exception {
|
||||
try (OutputStream os = IO.getOutputStream(IO.file("testOut/test.tar.gz"))) {
|
||||
CompressType.GZIP.ofCompress("testSrc").toStream(os);
|
||||
CompressType.GZIP.compressFrom("testSrc").toStream(os);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ public class GzipTest {
|
||||
public void testChainDecompressFromStream() throws Exception {
|
||||
byte[] bytes;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
CompressType.GZIP.ofCompress("testSrc").toStream(outputStream);
|
||||
CompressType.GZIP.compressFrom("testSrc").toStream(outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
}
|
||||
File out = IO.dir("testOutDeStream/gzip");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
GZipDecompressor decompressor = GZipDecompressor.of(new ByteArrayInputStream(bytes));
|
||||
GZipDecompressor decompressor = GZipDecompressor.from(new ByteArrayInputStream(bytes));
|
||||
Assertions.assertSame(
|
||||
decompressor,
|
||||
decompressor
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TarTest {
|
||||
|
||||
@Test
|
||||
public void testStaticCompress() throws Exception {
|
||||
TarCompressor compressor = TarCompressor.of("testSrc").toFile("testOut/test.tar");
|
||||
TarCompressor compressor = TarCompressor.from("testSrc").toFile("testOut/test.tar");
|
||||
Assertions.assertNotNull(compressor);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TarTest {
|
||||
File out = IO.file("testOut/test-chain.tar");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
TarCompressor compressor = TarCompressor.of("testSrc");
|
||||
TarCompressor compressor = TarCompressor.from("testSrc");
|
||||
Assertions.assertSame(
|
||||
compressor,
|
||||
compressor
|
||||
@@ -46,15 +46,15 @@ public class TarTest {
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.tar");
|
||||
TarCompressor.of("testSrc").toFile(in);
|
||||
TarCompressor.from("testSrc").toFile(in);
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).toPath(out.getAbsolutePath());
|
||||
CompressType.from(in).toPath(out.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressToStream() throws Exception {
|
||||
try (OutputStream os = IO.getOutputStream(IO.file("testOut/test.tar"))) {
|
||||
CompressType.TAR.ofCompress("testSrc").toStream(os);
|
||||
CompressType.TAR.compressFrom("testSrc").toStream(os);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ public class TarTest {
|
||||
public void testChainDecompressFromStream() throws Exception {
|
||||
byte[] bytes;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
CompressType.TAR.ofCompress("testSrc").toStream(outputStream);
|
||||
CompressType.TAR.compressFrom("testSrc").toStream(outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
}
|
||||
File out = IO.dir("testOutDeStream/tar");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
TarDecompressor decompressor = TarDecompressor.of(new ByteArrayInputStream(bytes));
|
||||
TarDecompressor decompressor = TarDecompressor.from(new ByteArrayInputStream(bytes));
|
||||
Assertions.assertSame(
|
||||
decompressor,
|
||||
decompressor
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Z7Test {
|
||||
|
||||
@Test
|
||||
public void testStaticCompress() throws Exception {
|
||||
Z7Compressor compressor = Z7Compressor.of("testSrc").toFile("testOut/test.7z");
|
||||
Z7Compressor compressor = Z7Compressor.from("testSrc").toFile("testOut/test.7z");
|
||||
Assertions.assertNotNull(compressor);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Z7Test {
|
||||
File out = IO.file("testOut/test-chain.7z");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
Z7Compressor compressor = Z7Compressor.of("testSrc");
|
||||
Z7Compressor compressor = Z7Compressor.from("testSrc");
|
||||
Assertions.assertSame(
|
||||
compressor,
|
||||
compressor
|
||||
@@ -45,15 +45,15 @@ public class Z7Test {
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.7z");
|
||||
Z7Compressor.of("testSrc").toFile(in);
|
||||
Z7Compressor.from("testSrc").toFile(in);
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).toPath(out.getAbsolutePath());
|
||||
CompressType.from(in).toPath(out.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressToStream() throws Exception {
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
CompressType.Z7.ofCompress("testSrc").toStream(outputStream);
|
||||
CompressType.Z7.compressFrom("testSrc").toStream(outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ public class Z7Test {
|
||||
public void testChainDecompressFromStream() throws Exception {
|
||||
byte[] bytes;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
CompressType.Z7.ofCompress("testSrc").toStream(outputStream);
|
||||
CompressType.Z7.compressFrom("testSrc").toStream(outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
}
|
||||
File out = IO.dir("testOutDeStream/z7");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
Z7Decompressor decompressor = Z7Decompressor.of(new ByteArrayInputStream(bytes));
|
||||
Z7Decompressor decompressor = Z7Decompressor.from(new ByteArrayInputStream(bytes));
|
||||
Assertions.assertSame(
|
||||
decompressor,
|
||||
decompressor
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ZipTest {
|
||||
|
||||
@Test
|
||||
public void testStaticCompress() throws Exception {
|
||||
ZipCompressor compressor = ZipCompressor.of("testSrc").toFile("testOut/test.zip");
|
||||
ZipCompressor compressor = ZipCompressor.from("testSrc").toFile("testOut/test.zip");
|
||||
Assertions.assertNotNull(compressor);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ZipTest {
|
||||
File out = IO.file("testOut/test-chain.zip");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
ZipCompressor compressor = ZipCompressor.of("testSrc");
|
||||
ZipCompressor compressor = ZipCompressor.from("testSrc");
|
||||
Assertions.assertSame(
|
||||
compressor,
|
||||
compressor
|
||||
@@ -45,15 +45,15 @@ public class ZipTest {
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.zip");
|
||||
ZipCompressor.of("testSrc").toFile(in);
|
||||
ZipCompressor.from("testSrc").toFile(in);
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).toPath(out.getAbsolutePath());
|
||||
CompressType.from(in).toPath(out.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressToStream() throws Exception {
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
CompressType.ZIP.ofCompress("testSrc").toStream(outputStream);
|
||||
CompressType.ZIP.compressFrom("testSrc").toStream(outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ public class ZipTest {
|
||||
public void testChainDecompressFromStream() throws Exception {
|
||||
byte[] bytes;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
CompressType.ZIP.ofCompress("testSrc").toStream(outputStream);
|
||||
CompressType.ZIP.compressFrom("testSrc").toStream(outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
}
|
||||
File out = IO.dir("testOutDeStream/zip");
|
||||
AtomicInteger fileCount = new AtomicInteger();
|
||||
AtomicReference<Double> progress = new AtomicReference<>(0D);
|
||||
ZipDecompressor decompressor = ZipDecompressor.of(new ByteArrayInputStream(bytes));
|
||||
ZipDecompressor decompressor = ZipDecompressor.from(new ByteArrayInputStream(bytes));
|
||||
Assertions.assertSame(
|
||||
decompressor,
|
||||
decompressor
|
||||
|
||||
Reference in New Issue
Block a user