Class FileSource

java.lang.Object
org.zeroturnaround.zip.FileSource
All Implemented Interfaces:
ZipEntrySource

public class FileSource extends Object implements ZipEntrySource
  • Field Details

    • path

      private final String path
    • file

      private final File file
  • Constructor Details

    • FileSource

      public FileSource(String path, File file)
  • Method Details

    • getPath

      public String getPath()
      Specified by:
      getPath in interface ZipEntrySource
      Returns:
      path of the given entry (not null).
    • getEntry

      public ZipEntry getEntry()
      Specified by:
      getEntry in interface ZipEntrySource
      Returns:
      meta-data of the given entry (not null).
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface ZipEntrySource
      Returns:
      an input stream of the given entry or null if this entry is a directory.
      Throws:
      IOException - can throw getting the InputStream
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • pair

      public static FileSource[] pair(File[] files, 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 array
      names - 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:
      IllegalArgumentException - if the names array contains less items than the files array