code: public void write(ProgressVisitor progress) throws SQLException {        
          if (FileUtil.isExtensionWellFormated(fileName, "kml")) {
              writeKML(progress);
          } else if (FileUtil.isExtensionWellFormated(fileName, "kmz")) {
              String name = fileName.getName();
              int pos = name.lastIndexOf(".");
              writeKMZ(progress, name.substring(0, pos) + ".kml");
          } else {
              throw new SQLException("Please use the extensions .kml or kmz.");
          }
      }
docs: Write spatial table to kml or kmz file format.
  
  @param progress
  @throws SQLException