Package loci.common
Class ZipHandle
- java.lang.Object
-
- loci.common.StreamHandle
-
- loci.common.ZipHandle
-
- All Implemented Interfaces:
DataInput,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
-
Nested classes/interfaces inherited from class loci.common.StreamHandle
StreamHandle.Settings
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this random access stream and releases any system resources associated with the stream.intgetEntryCount()StringgetEntryName()DataInputStreamgetInputStream()static booleanisZipFile(String file)protected voidresetStream()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 Detail
-
ZipHandle
public ZipHandle(String file) throws IOException
- Throws:
IOException
-
ZipHandle
public ZipHandle(String file, ZipEntry entry) throws IOException
Constructs 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.IOException- See Also:
ZipEntry
-
-
Method Detail
-
isZipFile
public static boolean isZipFile(String file) throws 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:
IOException- if the file cannot be read
-
getEntryName
public String getEntryName()
- Returns:
- the name of the backing Zip entry.
-
getInputStream
public 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 IOExceptionDescription copied from interface:IRandomAccessCloses this random access stream and releases any system resources associated with the stream.- Specified by:
closein interfaceIRandomAccess- Overrides:
closein classStreamHandle- Throws:
IOException- if the underlying stream(s) could not be closed
-
resetStream
protected void resetStream() throws IOExceptionDescription copied from class:StreamHandleClose 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:
resetStreamin classStreamHandle- Throws:
IOException- if the stream cannot be reset
-
-