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
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
close()
Closes this random access stream and releases any system resources associated with the stream.int
getEntryCount()
java.lang.String
getEntryName()
java.io.DataInputStream
getInputStream()
static boolean
isZipFile(java.lang.String file)
protected void
resetStream()
Close and reopen the stream; the stream pointer and mark should be reset to 0.Methods inherited from class loci.common.StreamHandle
exists, getFilePointer, getOrder, length, read, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setOrder, skipBytes, skipBytes, write, write, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
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.IOExceptionConstructs a new ZipHandle corresponding to the given entry of the specified Zip file.- Parameters:
file
- a name that can be passed toLocation.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 toLocation.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.IOExceptionDescription copied from interface:IRandomAccess
Closes this random access stream and releases any system resources associated with the stream.- Specified by:
close
in interfaceIRandomAccess
- Overrides:
close
in classStreamHandle
- Throws:
java.io.IOException
- if the underlying stream(s) could not be closed
-
resetStream
protected void resetStream() throws java.io.IOExceptionDescription 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 classStreamHandle
- Throws:
java.io.IOException
- if the stream cannot be reset
-