The RSS Stream Reader is very fast and performs real-time processing through the stream. Therefore, it can handle RSS without reading all of them. For example, by adding code to stop at duplicate items, it can end the stream without reading unnecessary duplicate items.
implementation("me.saro:rss-stream-reader:1.1")
compile "me.saro:rss-stream-reader:1.1"
<dependency>
<groupId>me.saro</groupId>
<artifactId>rss-stream-reader</artifactId>
<version>1.1</version>
</dependency>
// reader is thread-safe
val reader = RssStreamReader.Builder().build()
// normal
val rss = reader.url("https://test/rss.xml")
// print
println(rss)
println("- items")
rss.items.forEach(::println)
// stream stop
val rss = reader.url("https://test/rss.xml") { item, channel ->
if (lastLink == item.link) {
// The RSS feed stream has been stopped because the RSS feed items are duplicated.
return@url false
}
true
}
// reader is thread-safe
RssStreamReader reader = new RssStreamReader.Builder().build();
// normal
var rss = reader.url("https://test/rss.xml");
// print
System.out.println(rss);
System.out.println("- items");
rss.getItems().stream().forEach(System.out::println);
// stream stop
var rss = reader.url("https://test/rss.xml", (item, channel) -> {
if (lastLink.equals(item.getLink())) {
// The RSS feed stream has been stopped because the RSS feed items are duplicated.
return false;
}
return true;
});