Package loci.common

Class ZipHandle

java.lang.Object
loci.common.StreamHandle
loci.common.ZipHandle
All Implemented Interfaces:
java.io.DataInput, java.io.DataOutput, IRandomAccess

public class ZipHandle
extends StreamHandle
StreamHandle implementation for reading from Zip-compressed files or byte arrays. Instances of ZipHandle are read-only.
Author:
Melissa Linkert melissa at glencoesoftware.com
See Also:
StreamHandle
  • Constructor Details

    • ZipHandle

      public ZipHandle​(java.lang.String file) throws java.io.IOException
      Throws:
      java.io.IOException
    • ZipHandle

      public ZipHandle​(java.lang.String file, java.util.zip.ZipEntry entry) throws java.io.IOException
      Constructs a new ZipHandle corresponding to the given entry of the specified Zip file.
      Parameters:
      file - a name that can be passed to Location.getHandle(String, boolean, boolean)
      entry - the specific entry in the Zip file to be opened
      Throws:
      HandleException - if the given file is not a Zip file.
      java.io.IOException
      See Also:
      ZipEntry
  • Method Details

    • isZipFile

      public static boolean isZipFile​(java.lang.String file) throws java.io.IOException
      Parameters:
      file - a name that can be passed to Location.getHandle(String, boolean, boolean)
      Returns:
      true if the given filename is a Zip file.
      Throws:
      java.io.IOException - if the file cannot be read
    • getEntryName

      public java.lang.String getEntryName()
      Returns:
      the name of the backing Zip entry.
    • getInputStream

      public java.io.DataInputStream getInputStream()
      Returns:
      the DataInputStream corresponding to the backing Zip entry.
    • getEntryCount

      public int getEntryCount()
      Returns:
      the number of entries.
    • close

      public void close() throws java.io.IOException
      Description copied from interface: IRandomAccess
      Closes this random access stream and releases any system resources associated with the stream.
      Specified by:
      close in interface IRandomAccess
      Overrides:
      close in class StreamHandle
      Throws:
      java.io.IOException - if the underlying stream(s) could not be closed
    • resetStream

      protected void resetStream() throws java.io.IOException
      Description copied from class: StreamHandle
      Close and reopen the stream; the stream pointer and mark should be reset to 0. This method is called if we need to seek backwards within the stream.
      Specified by:
      resetStream in class StreamHandle
      Throws:
      java.io.IOException - if the stream cannot be reset