-1
    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();

I have a zip file, I want to download it when I call the api.With the zip file, I don't know how to download. Hope to get help from you.

gin
  • 11
  • 3

1 Answers1

0

If you are using Spring/Spring Boot. You can follow this stackoverflow thread Download File in Spring