🎨
Andy開發紀錄
  • 關於
    • 自介
  • 設計模式
    • 觀察者模型
    • 有限狀態機
    • 裝飾器模式
  • 其他
    • Scrum敏捷式開發
    • SOLID設計
    • TDD驅動測試開發
    • Event Driven Architecture
    • CQRS命令查詢職責分離
    • Concurrent並行相關
      • Single Thread Execution
      • 共用元件設計
        • CountDownLatchWorkPool
        • IForkWorkService
      • Pattern
        • THREAD-PER-MESSAGE
        • PRODUCER CONSUMER
        • SINGLE THREAD
        • Guarded Suspension 守衛模式
      • IQueue
        • ListQueue
        • BlockQueue
        • OrderBlockQueue
  • 元件設計
    • Sql Help
      • SQL Help Generate
      • StringBuilderGenerator
      • SQL Generate
    • excel工具
    • BDD行為驅動開發
    • 多工設計
      • 多工自動調整Thread數量
    • 常用Design Patten實作
    • Telegram Bot元件
    • 代碼元件
    • HCP API元件
    • 文字解析元件
    • MockitObject
    • 資料驗證元件
    • Zip壓縮工具
    • Sql Code Generate
  • 讀書心得
    • Clean code第一章
  • side project
    • 後端服務
  • IDEA
    • IDEA 外掛推薦
    • IDEA 外掛開發
Powered by GitBook
On this page

Was this helpful?

  1. 元件設計

Zip壓縮工具

建立簡單壓縮,可設定幾筆檔案包成一包與名稱策略

@Test
void testZip() throws URISyntaxException {

    ClassLoader classLoader = ZipServiceTest.class.getClassLoader();
    URL resource1 = classLoader.getResource("file1.txt");
    URL resource2 = classLoader.getResource("file2.txt");

    List<File> files = Arrays.asList(//
            new File(resource1.toURI()), //
            new File(resource2.toURI()));//

    ZipMakeOption option = new ZipMakeOption(this::getFileName, 1, "/ZIP");
    option.addAllFile(files);
    option.setMakeZipListener(file -> log.info("ok file size:{}", file.size()));
    List<File> makeZip = zipService.makeZip(option);
    assertThat(makeZip).isNotEmpty();
}
<dependency>
  <groupId>io.github.h8000572003</groupId>
  <artifactId>zip</artifactId>
  <version>0.0.1</version>
</dependency>
Previous資料驗證元件NextSql Code Generate

Last updated 2 years ago

Was this helpful?