Package net.datenwerke.rs.utils.zip
Class ZipUtilsServiceImpl
java.lang.Object
net.datenwerke.rs.utils.zip.ZipUtilsServiceImpl
- All Implemented Interfaces:
ZipUtilsService
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.datenwerke.rs.utils.zip.ZipUtilsService
ZipUtilsService.FileFilter -
Field Summary
Fields inherited from interface net.datenwerke.rs.utils.zip.ZipUtilsService
DIRECTORY_MARKER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncleanDirectoryName(String dirname) Replaces invalid characters from a directory name to be zipped with valid characters.cleanFilename(String filename) Replaces invalid characters from a filename to be zipped with valid characters.voidcreateZip(byte[] content, OutputStream os) voidcreateZip(String contentFilename, Object content, OutputStream os) Packs the given content into a zip archive.voidcreateZip(List<Path> files, OutputStream os) voidcreateZip(Map<String, ? extends Object> content, OutputStream os) Packs the given list of files and/or directories into a zip archive.voidcreateZip(FileServerFolder folder, OutputStream os) voidcreateZip(FileServerFolder folder, OutputStream os, ZipUtilsService.FileFilter filter) voidcreateZipFromEmailAttachments(List<SimpleAttachment> attachments, OutputStream os) voidextractZip(byte[] data, ZipExtractionConfig config) voidextractZip(InputStream is, ZipExtractionConfig config) voidzipDirectory(File dir, OutputStream os)
-
Constructor Details
-
ZipUtilsServiceImpl
public ZipUtilsServiceImpl()
-
-
Method Details
-
createZip
- Specified by:
createZipin interfaceZipUtilsService- Throws:
IOException
-
createZip
Description copied from interface:ZipUtilsServicePacks the given list of files and/or directories into a zip archive.- Specified by:
createZipin interfaceZipUtilsService- Parameters:
content- map containing the files to zip. In case of zipping files, the key contains the filename, while the value contains the object to be zipped. The object may be a String or a byte array. In case of zipping directories, the key contains the relative directory path, and the value containsZipUtilsService.DIRECTORY_MARKER. In this case, the files inside the given directory should contain the relative path to the file.Example zipping c.txt and mydirectory containing a.txt and b.txt:
- mydirectory=
ZipUtilsService.DIRECTORY_MARKER - mydirectory/a.txt="a"
- mydirectory/b.txt="b"
- c.txt="c"
- mydirectory=
os- the OutputStream where the zip should be written to- Throws:
IOException- if an I/O error has occurred
-
createZip
Description copied from interface:ZipUtilsServicePacks the given content into a zip archive.- Specified by:
createZipin interfaceZipUtilsService- Parameters:
contentFilename- the filename of the file to be zippedcontent- the content to be zipped. It may be a String or a byte arrayos- the OutputStream where the zip should be written to- Throws:
IOException- if an I/O error has occurred
-
createZip
- Specified by:
createZipin interfaceZipUtilsService- Throws:
IOException
-
createZipFromEmailAttachments
public void createZipFromEmailAttachments(List<SimpleAttachment> attachments, OutputStream os) throws IOException - Specified by:
createZipFromEmailAttachmentsin interfaceZipUtilsService- Throws:
IOException
-
zipDirectory
- Throws:
IOException
-
extractZip
- Specified by:
extractZipin interfaceZipUtilsService- Throws:
IOException
-
extractZip
- Specified by:
extractZipin interfaceZipUtilsService- Throws:
IOException
-
createZip
- Specified by:
createZipin interfaceZipUtilsService- Throws:
IOException
-
createZip
public void createZip(FileServerFolder folder, OutputStream os, ZipUtilsService.FileFilter filter) throws IOException - Specified by:
createZipin interfaceZipUtilsService- Throws:
IOException
-
cleanFilename
Description copied from interface:ZipUtilsServiceReplaces invalid characters from a filename to be zipped with valid characters.- Specified by:
cleanFilenamein interfaceZipUtilsService- Parameters:
filename- the filename to be cleaned- Returns:
- the cleaned filename
-
cleanDirectoryName
Description copied from interface:ZipUtilsServiceReplaces invalid characters from a directory name to be zipped with valid characters.- Specified by:
cleanDirectoryNamein interfaceZipUtilsService- Parameters:
dirname- the directory name to be cleaned- Returns:
- the cleaned directory name
-