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