Package org.zeroturnaround.zip
Class FileSource
- java.lang.Object
-
- org.zeroturnaround.zip.FileSource
-
- All Implemented Interfaces:
ZipEntrySource
public class FileSource extends java.lang.Object implements ZipEntrySource
-
-
Constructor Summary
Constructors Constructor Description FileSource(java.lang.String path, java.io.File file)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.zip.ZipEntry
getEntry()
java.io.InputStream
getInputStream()
java.lang.String
getPath()
static FileSource[]
pair(java.io.File[] files, java.lang.String[] names)
Creates a sequence of FileSource objects via mapping a sequence of files to the sequence of corresponding names for the entriesjava.lang.String
toString()
-
-
-
Method Detail
-
getPath
public java.lang.String getPath()
- Specified by:
getPath
in interfaceZipEntrySource
- Returns:
- path of the given entry (not
null
).
-
getEntry
public java.util.zip.ZipEntry getEntry()
- Specified by:
getEntry
in interfaceZipEntrySource
- Returns:
- meta-data of the given entry (not
null
).
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
- Specified by:
getInputStream
in interfaceZipEntrySource
- Returns:
- an input stream of the given entry
or
null
if this entry is a directory. - Throws:
java.io.IOException
- can throw getting the InputStream
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
pair
public static FileSource[] pair(java.io.File[] files, java.lang.String[] names)
Creates a sequence of FileSource objects via mapping a sequence of files to the sequence of corresponding names for the entries- Parameters:
files
- file array to form the data of the objects in the resulting arraynames
- file array to form the names of the objects in the resulting array- Returns:
- array of FileSource objects created by mapping given files array to the given names array one by one
- Throws:
java.lang.IllegalArgumentException
- if the names array contains less items than the files array
-
-