de.innovationgate.utils
public class DirZipper extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
DirZipper.DefaultInputStreamProvider
Default implementation of InputStreamProvider that just returns
plain FileInputStream-Objects for files
|
static interface |
DirZipper.InputStreamProvider
A provider of input streams for individual files in the directory to zip up.
|
Constructor and Description |
---|
DirZipper() |
Modifier and Type | Method and Description |
---|---|
void |
addFilePatternToIgnore(java.lang.String name)
Adds a file name pattern as regular expression that should be ignored when zipping the directory.
|
DirZipper.InputStreamProvider |
getInputStreamProvider()
Returns the input stream provider that the DirZipper will use to fetch
input streams for indidivual files
|
void |
setInputStreamProvider(DirZipper.InputStreamProvider inputStreamProvider)
Sets the input stream provider that the DirZipper will use to fetch
input streams for indidivual files
|
void |
unzipDirectory(java.io.File targetDir,
java.util.zip.ZipInputStream zis)
Unzips the content of the given input stream to a directory
|
void |
zipDirectory(java.io.File zipDir,
java.util.zip.ZipOutputStream zos)
Zips a directory to a zip output stream.
|
void |
zipDirectory(java.io.File zipDir,
java.util.zip.ZipOutputStream zos,
java.lang.String qualifier)
Zips the contents of a local directory to a ZIP archive
|
void |
zipFile(java.io.File file,
java.util.zip.ZipOutputStream zos)
Zips a file or directory to the output stream
|
void |
zipNormalFile(java.io.File f,
java.util.zip.ZipOutputStream zos,
java.lang.String qualifier)
Zips a single normal file (no directory!)
|
public void zipDirectory(java.io.File zipDir, java.util.zip.ZipOutputStream zos) throws java.io.IOException
zipDir
- The directory whose contents will be in the zip filezos
- The zip output stream adressing the correct target for zipped datajava.io.IOException
public void zipFile(java.io.File file, java.util.zip.ZipOutputStream zos) throws java.io.IOException
file
- The file to zip. In case of a directory all the contents will be zippedzos
- The ZIP output streamjava.io.IOException
public void unzipDirectory(java.io.File targetDir, java.util.zip.ZipInputStream zis) throws java.io.IOException
targetDir
- The directory where to unzip the data tozis
- The input streamjava.io.IOException
- if something goes horribly wrongpublic void zipDirectory(java.io.File zipDir, java.util.zip.ZipOutputStream zos, java.lang.String qualifier) throws java.io.IOException
zipDir
- The directory to zip, including all contained fileszos
- The zip output streamqualifier
- Some qualifier identifying the directory inside the zip to which the file should be put. Specify an empty string to make it a root file. Specify some dir path ending with "/" to put it to a directory.java.io.IOException
public void zipNormalFile(java.io.File f, java.util.zip.ZipOutputStream zos, java.lang.String qualifier) throws java.io.FileNotFoundException, java.io.IOException
f
- The filezos
- The zip output streamqualifier
- Some qualifier identifying the directory inside the zip to which the file should be put. Specify an empty string to make it a root file. Specify some dir path ending with "/" to put it to a directory.java.io.FileNotFoundException
java.io.IOException
public DirZipper.InputStreamProvider getInputStreamProvider()
public void setInputStreamProvider(DirZipper.InputStreamProvider inputStreamProvider)
inputStreamProvider
- The provider to usepublic void addFilePatternToIgnore(java.lang.String name)
name
- The pattern to ignore