public class KMZFile extends 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 Map<String,File> |
files
A mapping of the files in the KMZ file to their location in the temporary directory.
|
protected File |
tempDir
The directory to hold files copied from the KMZ file.
|
protected ZipFile |
zipFile
The
ZipFile reference specified to the constructor. |
Constructor and Description |
---|
KMZFile(File file)
Construct a KMZFile instance.
|
Modifier and Type | Method and Description |
---|---|
protected String |
copyEntryToTempDir(ZipEntry entry)
Copies a zip entry to a temporary file.
|
InputStream |
getKMLStream()
Returns an
InputStream to the first KML file in the KMZ file. |
String |
getSupportFilePath(String path)
Returns an absolute path to a specified file within the KMZ file.
|
InputStream |
getSupportFileStream(String path)
Returns an
InputStream to a specified file within the KMZ file. |
ZipFile |
getZipFile()
Returns the file file specified to the constructor as a
ZipFile . |
protected Map<String,File> files
protected File tempDir
public KMZFile(File file) throws IOException
file
- path to the KMZ file.IOException
- if an error occurs while attempting to query or open the file.IllegalArgumentException
- if the specified file is null.ZipException
- if a Zip error occurs.protected String copyEntryToTempDir(ZipEntry entry) throws IOException
entry
- the entry to copy.IOException
- if an error occurs during the copy.public InputStream getKMLStream() throws IOException
InputStream
to the first KML file in the KMZ file.getKMLStream
in interface KMLDoc
IOException
- if an error occurs while attempting to create or open the input stream.public String getSupportFilePath(String path) throws IOException
getSupportFilePath
in interface KMLDoc
path
- the path of the requested file.IllegalArgumentException
- if the path is null.IOException
- if an error occurs while attempting to create a temporary file.public InputStream getSupportFileStream(String path) throws 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 KMLDoc
path
- the path of the requested file.IllegalArgumentException
- if the path is null.IOException
- if an error occurs while attempting to create or open the input stream.