This library generates a web sitemap and can ping Google that it has changed. This project has been inspired by sitemapgen4j, but is much more focused on traditional web sitemap and ease of use.
First add this library to classpath:
<dependency>
<groupId>cz.jiripinkas</groupId>
<artifactId>jsitemapgenerator</artifactId>
<version>2.1</version>
</dependency>
If you want to use "ping google / bing" functionality, also add this library to classpath:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.2</version>
</dependency>
// create web sitemap for web http://www.javavids.com
SitemapGenerator sitemapGenerator = new SitemapGenerator("http://www.javavids.com");
// add some URLs
sitemapGenerator.addPage(new WebPageBuilder().name("index.php")
.priorityMax().changeFreqNever().lastModNow().build());
sitemapGenerator.addPage(new WebPageBuilder().name("latest.php").build());
sitemapGenerator.addPage(new WebPageBuilder().name("contact.php").build());
// generate sitemap and save it to file /var/www/sitemap.xml
File file = new File("/var/www/sitemap.xml");
sitemapGenerator.constructAndSaveSitemap(file);
// inform Google that this sitemap has changed
sitemapGenerator.pingGoogle();
SitemapIndexGenerator sitemapIndexGenerator = new SitemapIndexGenerator("http://javalibs.com");
sitemapIndexGenerator.addPage(new WebPageBuilder().name("sitemap-plugins.xml").build());
sitemapIndexGenerator.addPage(new WebPageBuilder().name("sitemap-archetypes.xml").build());
System.out.println(sitemapIndexGenerator.constructSitemapString());
RssGenerator rssGenerator = new RssGenerator("http://www.topjavablogs",
"Top Java Blogs", "Best Java Blogs");
rssGenerator.addPage(new RssItemBuilder().pubDate(new Date()).title("News Title")
.description("News Description").name("page-name").build());
System.out.println(rssGenerator.constructRss());
- Java video tutorials (free online tutorials)
- Website monitoring software (free OSS software)
- Java skoleni (in Czech)
- SQL skoleni (in Czech)