public class ZipUtilsServiceImpl extends java.lang.Object implements ZipUtilsService
ZipUtilsService.FileFilter
DIRECTORY_MARKER
Constructor and Description |
---|
ZipUtilsServiceImpl() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
cleanDirectoryName(java.lang.String dirname)
Replaces invalid characters from a directory name to be zipped with valid
characters.
|
java.lang.String |
cleanFilename(java.lang.String filename)
Replaces invalid characters from a filename to be zipped with valid
characters.
|
void |
createZip(byte[] content,
java.io.OutputStream os) |
void |
createZip(FileServerFolder folder,
java.io.OutputStream os) |
void |
createZip(FileServerFolder folder,
java.io.OutputStream os,
ZipUtilsService.FileFilter filter) |
void |
createZip(java.util.List<java.nio.file.Path> files,
java.io.OutputStream os) |
void |
createZip(java.util.Map<java.lang.String,? extends java.lang.Object> content,
java.io.OutputStream os)
Packs the given list of files and/or directories into a zip archive.
|
void |
createZip(java.lang.String contentFilename,
java.lang.Object content,
java.io.OutputStream os)
Packs the given content into a zip archive.
|
void |
createZipFromEmailAttachments(java.util.List<SimpleAttachment> attachments,
java.io.OutputStream os) |
void |
extractZip(byte[] data,
ZipExtractionConfig config) |
void |
extractZip(java.io.InputStream is,
ZipExtractionConfig config) |
void |
zipDirectory(java.io.File dir,
java.io.OutputStream os) |
public void createZip(byte[] content, java.io.OutputStream os) throws java.io.IOException
createZip
in interface ZipUtilsService
java.io.IOException
public void createZip(java.util.Map<java.lang.String,? extends java.lang.Object> content, java.io.OutputStream os) throws java.io.IOException
ZipUtilsService
createZip
in interface ZipUtilsService
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 contains
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:
DIRECTORY_MARKER
os
- the OutputStream where the zip should be written tojava.io.IOException
- if an I/O error has occurredpublic void createZip(java.lang.String contentFilename, java.lang.Object content, java.io.OutputStream os) throws java.io.IOException
ZipUtilsService
createZip
in interface ZipUtilsService
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 tojava.io.IOException
- if an I/O error has occurredpublic void createZip(java.util.List<java.nio.file.Path> files, java.io.OutputStream os) throws java.io.IOException
createZip
in interface ZipUtilsService
java.io.IOException
public void createZipFromEmailAttachments(java.util.List<SimpleAttachment> attachments, java.io.OutputStream os) throws java.io.IOException
createZipFromEmailAttachments
in interface ZipUtilsService
java.io.IOException
public void zipDirectory(java.io.File dir, java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void extractZip(byte[] data, ZipExtractionConfig config) throws java.io.IOException
extractZip
in interface ZipUtilsService
java.io.IOException
public void extractZip(java.io.InputStream is, ZipExtractionConfig config) throws java.io.IOException
extractZip
in interface ZipUtilsService
java.io.IOException
public void createZip(FileServerFolder folder, java.io.OutputStream os) throws java.io.IOException
createZip
in interface ZipUtilsService
java.io.IOException
public void createZip(FileServerFolder folder, java.io.OutputStream os, ZipUtilsService.FileFilter filter) throws java.io.IOException
createZip
in interface ZipUtilsService
java.io.IOException
public java.lang.String cleanFilename(java.lang.String filename)
ZipUtilsService
cleanFilename
in interface ZipUtilsService
filename
- the filename to be cleanedpublic java.lang.String cleanDirectoryName(java.lang.String dirname)
ZipUtilsService
cleanDirectoryName
in interface ZipUtilsService
dirname
- the directory name to be cleaned