com.atlassian.jira.issue.attachment
Class AttachmentZipKit

java.lang.Object
  extended by com.atlassian.jira.issue.attachment.AttachmentZipKit

public class AttachmentZipKit
extends Object

This class will help when working with zip files

Since:
4.1

Nested Class Summary
static interface AttachmentZipKit.AttachmentZipEntry
          These are the data returned about entries in a zip file
static interface AttachmentZipKit.AttachmentZipEntryList<E>
           
static class AttachmentZipKit.ZipEntryInputStream
           
 
Constructor Summary
AttachmentZipKit()
           
 
Method Summary
 AttachmentZipKit.ZipEntryInputStream extractFile(File zipFile, long entryIndex)
          This will extract an OutputStream of the contents of the file at entryIndex within the zip file.
 boolean isZip(File zipFile)
          This will return true if the file is in fact a valid zip file
 AttachmentZipKit.AttachmentZipEntryList<AttachmentZipKit.AttachmentZipEntry> listFile(File zipFile, int maxEntries)
          This will return a list of AttachmentZipKit.AttachmentZipEntrys for a given zip file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentZipKit

public AttachmentZipKit()
Method Detail

isZip

public boolean isZip(File zipFile)
This will return true if the file is in fact a valid zip file

Parameters:
zipFile - the file in play
Returns:
true if its actualyl a readable zip file

extractFile

public AttachmentZipKit.ZipEntryInputStream extractFile(File zipFile,
                                                        long entryIndex)
                                                 throws IOException
This will extract an OutputStream of the contents of the file at entryIndex within the zip file. If no file can be found be at that index or the entry is a directory then null will be returned.

Parameters:
zipFile - the zip file in play
entryIndex - the index of the entry to return
Returns:
an AttachmentZipKit.ZipEntryInputStream that can be read from for data and has extra ZipEntry information
Throws:
IOException - if things go wrong during reading

listFile

public AttachmentZipKit.AttachmentZipEntryList<AttachmentZipKit.AttachmentZipEntry> listFile(File zipFile,
                                                                                             int maxEntries)
                                                                                      throws IOException
This will return a list of AttachmentZipKit.AttachmentZipEntrys for a given zip file

Parameters:
zipFile - the ZIP file in play
maxEntries - the maximum number of entries to put in th list. If this is -negative then not maximum is used.
Returns:
a list of entries
Throws:
IOException - if the file cant be read and ZipException if the the file is not a zip file.


Copyright © 2002-2010 Atlassian. All Rights Reserved.