{{theTime}}

Search This Blog

Total Pageviews

Java Program to read website RSS(really simple syndication)

/**
* @(#)WebSiteConnector.java
*
*
* @author Sriprasad.
* @version 1.00 2007/11/20
*/

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter ;
import java.io.FileWriter ;

public class WebSiteConnector
{
public static void main(String args[])
{
try {
URL url = new URL("http://developers.sun.com/rss/java.xml") ; //http://www.codingforums.com/external.php?type=RSS2"); //Coding Forums RSS Feed
HttpURLConnection huc = (HttpURLConnection)url.openConnection();
huc.setRequestMethod("GET");
huc.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; JVM)");
huc.setRequestProperty("Pragma", "no-cache");
huc.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(huc.getInputStream()));

String line = null;
//StringBuffer sb = new StringBuffer("") ;
PrintWriter pw = new PrintWriter( new FileWriter("java.rss")) ;
while ((line = reader.readLine()) != null) {
pw.println( line ) ;
//sb.append(line) ;
// Either do your parsing here, or append it to a StringBuffer for later use
}
//System.out.println( sb ) ;
pw.close() ;
huc.disconnect() ;
} catch(IOException ioe)
{
ioe.printStackTrace();
}
catch(Exception e)
{
System.err.println("General Exception " + e);
e.printStackTrace();
}
}

}

No comments:

Kafka Consumer Parallelism

Kafka Parallel Consumer Options: Key-level parallelism:  Multiple threads process the messages from a single partition in parallel while ma...