com.marringtons.file
Class ZipOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.util.zip.DeflaterOutputStream
java.util.zip.ZipOutputStream
com.marringtons.file.ZipOutputStream
- All Implemented Interfaces:
- ZipConstants
- public class ZipOutputStream
- extends ZipOutputStream
This class is a wrapper to simplify archive file creation and update code.
There are times when we want to create/append information to an archive. This
class adds additional tools to the standard library method for easy
creation/maintenance and an attached writer when text output is required.
ZipOutputStream out = new ZipOutputStream(fileName, false);
out.putNextEntry("testPutNextEntryString");
Writer writer = out.getWriter();
writer.write("abc\ndef");
out.putNextEntry("b/testPutNextEntryString");
writer.write("ghi\njkl");
out.close();
- Author:
- Paul Marrington
- See Also:
OutputStream
| Fields inherited from class java.util.zip.ZipOutputStream |
CENATT, CENATX, CENCOM, CENCRC, CENDSK, CENEXT, CENFLG, CENHDR, CENHOW, CENLEN, CENNAM, CENOFF, CENSIG, CENSIZ, CENTIM, CENVEM, CENVER, DEFLATED, ENDCOM, ENDHDR, ENDOFF, ENDSIG, ENDSIZ, ENDSUB, ENDTOT, EXTCRC, EXTHDR, EXTLEN, EXTSIG, EXTSIZ, LOCCRC, LOCEXT, LOCFLG, LOCHDR, LOCHOW, LOCLEN, LOCNAM, LOCSIG, LOCSIZ, LOCTIM, LOCVER, STORED |
|
Constructor Summary |
ZipOutputStream(String name,
boolean append)
Given a file name, create or append to a zip file. |
|
Method Summary |
void |
close()
Close a zip file - flushing any existing writer. |
void |
closeEntry()
Close a zip entry - flushing any existing writer. |
Writer |
getWriter()
A ZipOutputStream by itself is fairly useless. |
void |
putNextEntry(String path)
Start a new Zip file entry with a given path name. |
ZipOutputStream
public ZipOutputStream(String name,
boolean append)
throws FileNotFoundException
- Given a file name, create or append to a zip file.
- Parameters:
name - of zip fileappend - true to add to file, false to create new file (or clear old)
- Throws:
FileNotFoundException
putNextEntry
public void putNextEntry(String path)
throws IOException
- Start a new Zip file entry with a given path name.
- Parameters:
path - used to find and extract entry.
- Throws:
IOException- See Also:
ZipOutputStream.putNextEntry(java.util.zip.ZipEntry)
closeEntry
public void closeEntry()
throws IOException
- Close a zip entry - flushing any existing writer.
- Throws:
IOException
close
public void close()
throws IOException
- Close a zip file - flushing any existing writer.
- Throws:
IOException
getWriter
public Writer getWriter()
- A ZipOutputStream by itself is fairly useless. Use this method to create/retrieve
a writer to handle the stream more easily.
- Returns:
- the writer associated with this stream - creating it if necessary.
Copyright © 2005 Paul Marrington http://library.marringtons.com