public class KMZFile extends java.lang.Object implements KMLDoc
KMLDoc interface for KMZ files located within a computer's file system.
Note: This class does not yet resolve references to files in other KMZ archives. For example, it does not resolve references like this: ../other.kmz/file.png.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.io.File> |
files
A mapping of the files in the KMZ file to their location in the temporary directory.
|
protected java.io.File |
tempDir
The directory to hold files copied from the KMZ file.
|
protected java.util.zip.ZipFile |
zipFile
The
ZipFile reference specified to the constructor. |
| Constructor and Description |
|---|
KMZFile(java.io.File file)
Construct a KMZFile instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
copyEntryToTempDir(java.util.zip.ZipEntry entry)
Copies a zip entry to a temporary file.
|
java.io.InputStream |
getKMLStream()
Returns an
InputStream to the first KML file in the KMZ file. |
java.lang.String |
getSupportFilePath(java.lang.String path)
Returns an absolute path to a specified file within the KMZ file.
|
java.io.InputStream |
getSupportFileStream(java.lang.String path)
Returns an
InputStream to a specified file within the KMZ file. |
java.util.zip.ZipFile |
getZipFile()
Returns the file file specified to the constructor as a
ZipFile. |
protected java.util.Map<java.lang.String,java.io.File> files
protected java.io.File tempDir
protected java.util.zip.ZipFile zipFile
ZipFile reference specified to the constructor.public KMZFile(java.io.File file)
throws java.io.IOException
file - path to the KMZ file.java.io.IOException - if an error occurs while attempting to query or open the file.java.lang.IllegalArgumentException - if the specified file is null.java.util.zip.ZipException - if a Zip error occurs.protected java.lang.String copyEntryToTempDir(java.util.zip.ZipEntry entry)
throws java.io.IOException
entry - the entry to copy.java.io.IOException - if an error occurs during the copy.public java.io.InputStream getKMLStream()
throws java.io.IOException
InputStream to the first KML file in the KMZ file.getKMLStream in interface KMLDocjava.io.IOException - if an error occurs while attempting to create or open the input stream.public java.lang.String getSupportFilePath(java.lang.String path)
throws java.io.IOException
Note: This class does not yet resolve references to files in other KMZ archives. For example, it does not resolve references like this: ../other.kmz/file.png. // TODO
getSupportFilePath in interface KMLDocpath - the path of the requested file.java.lang.IllegalArgumentException - if the path is null.java.io.IOException - if an error occurs while attempting to create a temporary file.public java.io.InputStream getSupportFileStream(java.lang.String path)
throws java.io.IOException
InputStream to a specified file within the KMZ file. The file's path is resolved relative to
the internal root of the KMZ file.
Note: This class does not yet resolve references to files in other KMZ archives. For example, it does not resolve references like this: ../other.kmz/file.png.
getSupportFileStream in interface KMLDocpath - the path of the requested file.java.lang.IllegalArgumentException - if the path is null.java.io.IOException - if an error occurs while attempting to create or open the input stream.public java.util.zip.ZipFile getZipFile()
ZipFile.ZipFile.