【问题标题】:Download zip file when call api调用api时下载zip文件
【发布时间】:2021-09-10 11:32:23
【问题描述】:
    FileOutputStream fos = new FileOutputStream(FILE_NAME);
    ZipOutputStream zipOut = new ZipOutputStream(fos);
    for (File file : files) {
        FileInputStream fis = new FileInputStream(file);
        ZipEntry zipEntry = new ZipEntry(file.getName());
        zipOut.putNextEntry(zipEntry);
        byte[] bytes = new byte[1024];
        int length;
        while((length = fis.read(bytes)) >= 0) {
            zipOut.write(bytes, 0, length);
        }
        fis.close();
    }
    zipOut.close();
    fos.close();

我有一个zip文件,我想在调用api时下载它。有了zip文件,我不知道如何下载。希望能得到您的帮助。

【问题讨论】:

    标签: java spring pdf zip rest


    【解决方案1】:

    如果您使用的是 Spring/Spring Boot。你可以关注这个stackoverflow线程Download File in Spring

    【讨论】:

      猜你喜欢
      • 2021-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-22
      • 2015-10-18
      相关资源
      最近更新 更多