Package org.projecthusky.common.utils
Class ZipCreator
java.lang.Object
org.projecthusky.common.utils.ZipCreator
This class provides the functions to create zip files
-
Constructor Summary
ConstructorsConstructorDescriptionZipCreator(OutputStream outputStream) Creates a new Object which provides the needed methodsZipCreator(String filePath) Creates a new Object which provides the needed methods -
Method Summary
Modifier and TypeMethodDescriptionvoidaddZipItem(InputStream data, String pathInZipFile) Adds an InputStream as ZipEntry to the ZipFilevoidaddZipItem(String pathInZipFile) Adds a directory as ZipEntry to the ZipFilevoidaddZipItem(String filePath, String pathInZipFile) Adds an InputStream as ZipEntry to the ZipFilevoidcloseZip()Closes the stream.
-
Constructor Details
-
ZipCreator
Creates a new Object which provides the needed methods- Parameters:
outputStream- the outputStream, which is used to write the contents to
-
ZipCreator
Creates a new Object which provides the needed methods- Parameters:
filePath- the path to the file, which is used to write the contents to
-
-
Method Details
-
addZipItem
Adds an InputStream as ZipEntry to the ZipFile- Parameters:
data- Contains the file to compress as InputStreampathInZipFile- Contains the relative path only in that zip file- Throws:
IOException- if the file could not be read
-
addZipItem
Adds a directory as ZipEntry to the ZipFile- Parameters:
pathInZipFile- Contains the relative path only in that zip file- Throws:
IOException- if the file could not be read
-
addZipItem
Adds an InputStream as ZipEntry to the ZipFile- Parameters:
filePath- Contains the path to the file to add as zip itempathInZipFile- Contains the relative path only in that zip file- Throws:
IOException- if the file could not be read
-
closeZip
Closes the stream. It only has to be called when no more entries will be added.- Throws:
IOException- if the file could not be read
-