|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.evanmclean.evlib.util.zip.Zipper
public class Zipper
Convenience wrapper around a ZipOutputStream
to easily add files and
folders to a zip file.
Nested Class Summary | |
---|---|
static class |
Zipper.FolderAction
Action to take for folders when recursively adding the contents of a folder. |
Field Summary | |
---|---|
static int |
DEFLATED
Compression method for compressed (DEFLATED) entries. |
static int |
STORED
Compression method for uncompressed (STORED) entries. |
Constructor Summary | |
---|---|
Zipper(File file)
Create a zip to the specified file with the default Zipper.FolderAction of
Zipper.FolderAction.ADD . |
|
Zipper(File file,
Zipper.FolderAction folder_action)
Zip to the specified file. |
|
Zipper(OutputStream out)
Create a zip to the specified output stream with the default Zipper.FolderAction of Zipper.FolderAction.ADD . |
|
Zipper(OutputStream out,
Zipper.FolderAction folder_action)
Create a zip to the specified output stream. |
|
Zipper(ZipOutputStream out)
Create a zip to the specified zip output stream with the default Zipper.FolderAction of Zipper.FolderAction.ADD . |
|
Zipper(ZipOutputStream out,
Zipper.FolderAction folder_action)
Create a zip to the specified zip output stream. |
Method Summary | |
---|---|
void |
close()
Closes the zip output stream as well as the underlying stream. |
void |
copy(File file)
Copy a file into the zip, just using the base name of the file. |
void |
copy(File folder,
boolean zip_folder_name)
Recursively copy all files in a folder into the zip. |
void |
copy(File file,
String name)
Copy the file into the zip, using the specified file name. |
void |
copy(InputStream in,
String name)
Read the input stream into the zip, using the specified file name. |
void |
finish()
Finishes writing the contents of the zip output stream without closing the underlying stream. |
Zipper.FolderAction |
getFolderAction()
Get the current Zipper.FolderAction that is used for calls to
copy(File, boolean) . |
void |
setComment(String comment)
Set the comment to be included in the zip file. |
void |
setFolderAction(Zipper.FolderAction folder_action)
Set the Zipper.FolderAction to be used for calls to
copy(File, boolean) . |
void |
setLevel(int level)
Set the compression level to a value between 0 (none), 1 (fast) and 9 (best). |
void |
setMethod(int method)
Sets the default compression method for subsequent entries. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFLATED
public static final int STORED
Constructor Detail |
---|
public Zipper(File file) throws FileNotFoundException
Zipper.FolderAction
of
Zipper.FolderAction.ADD
.
file
- File to create as a zip file.
FileNotFoundException
public Zipper(File file, Zipper.FolderAction folder_action) throws FileNotFoundException
file
- File to create as a zip file.folder_action
- The Zipper.FolderAction
to use.
FileNotFoundException
public Zipper(OutputStream out)
Zipper.FolderAction
of Zipper.FolderAction.ADD
.
out
- Output stream to write as a zip file.public Zipper(OutputStream out, Zipper.FolderAction folder_action)
out
- Output stream to write as a zip file.folder_action
- The Zipper.FolderAction
to use.public Zipper(ZipOutputStream out)
Zipper.FolderAction
of Zipper.FolderAction.ADD
.
out
- Zip output stream to write as a zip file.public Zipper(ZipOutputStream out, Zipper.FolderAction folder_action)
out
- Zip output stream to write as a zip file.folder_action
- The Zipper.FolderAction
to use.Method Detail |
---|
public void close() throws IOException
IOException
public void copy(File file) throws IOException
file
-
IOException
public void copy(File folder, boolean zip_folder_name) throws IOException
folder
- Folder to copy.zip_folder_name
- If true, then the name of the folder
is used as the
base folder for all the files within the zip, otherwise files and
folders are stored relative to the root of the zip file.
IOException
public void copy(File file, String name) throws IOException
file
- The file to zip.name
- The name for the file within the zip, which may include a path
component.
IOException
public void copy(InputStream in, String name) throws IOException
in
- The input to zip.name
- The name for the file within the zip, which may include a path
component.
IOException
public void finish() throws IOException
IOException
public Zipper.FolderAction getFolderAction()
Zipper.FolderAction
that is used for calls to
copy(File, boolean)
.
Zipper.FolderAction
public void setComment(String comment)
comment
- The comment.public void setFolderAction(Zipper.FolderAction folder_action)
Zipper.FolderAction
to be used for calls to
copy(File, boolean)
.
folder_action
- See Zipper.FolderAction
public void setLevel(int level)
level
- Compression level to use.public void setMethod(int method)
DEFLATED
.
method
- One of STORED
or DEFLATED
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |