From 78a9936ebcfa1dc570e87bf9a03e0a9427f9095e Mon Sep 17 00:00:00 2001 From: Gregor Koukkoullis Date: Tue, 3 Jan 2017 21:20:09 +0100 Subject: [PATCH] ability to specify sitemap index file --- .../sitemapgenerator/SitemapGenerator.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/redfin/sitemapgenerator/SitemapGenerator.java b/src/main/java/com/redfin/sitemapgenerator/SitemapGenerator.java index 65ebfd6..66f41f9 100644 --- a/src/main/java/com/redfin/sitemapgenerator/SitemapGenerator.java +++ b/src/main/java/com/redfin/sitemapgenerator/SitemapGenerator.java @@ -162,7 +162,7 @@ abstract class SitemapGenerator write() { @@ -208,14 +208,25 @@ abstract class SitemapGenerator"); } - /** After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated. - * + /** + * After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated. + * The sitemap index is written to {baseDir}/sitemap_index.xml */ public void writeSitemapsWithIndex() { if (!finished) throw new RuntimeException("Sitemaps not generated yet; call write() first"); File outFile = new File(baseDir, "sitemap_index.xml"); - SitemapIndexGenerator sig; - sig = new SitemapIndexGenerator.Options(baseUrl, outFile).dateFormat(dateFormat).autoValidate(autoValidate).build(); + writeSitemapsWithIndex(outFile); + } + + /** + * After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated. + * + * @param outFile the destination file of the sitemap index. + */ + public void writeSitemapsWithIndex(File outFile) { + if (!finished) throw new RuntimeException("Sitemaps not generated yet; call write() first"); + SitemapIndexGenerator sig; + sig = new SitemapIndexGenerator.Options(baseUrl, outFile).dateFormat(dateFormat).autoValidate(autoValidate).build(); sig.addUrls(fileNamePrefix, fileNameSuffix, mapCount).write(); }