Class ZipBuilder

java.lang.Object
org.activiti.cloud.services.common.zip.ZipBuilder

public class ZipBuilder extends Object
Builder for zip content
  • Constructor Details

    • ZipBuilder

      public ZipBuilder(String name)
  • Method Details

    • appendFolder

      public ZipBuilder appendFolder(String... path)
      Append a folder to the zip content. The path of the folder to be appended is given as an array of folder names.
      Parameters:
      path - the path of the folder
      Returns:
      this
    • appendFile

      public ZipBuilder appendFile(byte[] content, String... path)
      Append a file to the zip content. The path of the file to be appended is given as an array of folder names ended with the file name.
      Parameters:
      content - the file content
      path - the path of the file
      Returns:
      this
    • appendFile

      public ZipBuilder appendFile(FileContent fileContent, String... path)
      Append a file to the zip content. The path of the file to be appended is given as an array of folder names. The file name will be appended to this path.
      Parameters:
      fileContent - the file content
      path - the folders path
      Returns:
      this
    • toByteArrayOutputStream

      public ByteArrayOutputStream toByteArrayOutputStream() throws IOException
      Build the zip content stream based on collected folder and files.
      Returns:
      the zip content as byte array output stream
      Throws:
      IOException - in case of I/O error
    • writeToFile

      public void writeToFile(File file) throws IOException
      Write the zip content into the provided file.
      Parameters:
      file - the file where the zip file will be written to
      Throws:
      IOException - in case of I/O error
    • toZipBytes

      public byte[] toZipBytes() throws IOException
      Build the zip content based on collected folder and files.
      Returns:
      the zip content as byte array
      Throws:
      IOException - in case of I/O error
    • toZipFileContent

      public FileContent toZipFileContent() throws IOException
      Build the zip content as FileContent
      Returns:
      the FileContent
      Throws:
      IOException - in case of I/O error