Extract paragraph from html

hi i got this piece of code from this forum, and am not being able to modify it so it returns only texts within the

tags can any one help me out

import java.io.*;

import java.net.*;

import javax.swing.text.*;

import javax.swing.text.html.*;

class GetHTMLText

{

public static void main(String[] args)

throws Exception

{

EditorKit kit = new HTMLEditorKit();

Document doc = kit.createDefaultDocument();

// The Document class does not yet handle charset's properly.

doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);

// Create a reader on the HTML content.

Reader rd = getReader(args[0]);

// Parse the HTML.

kit.read(rd, doc, 0);

// The HTML text is now stored in the document

System.out.println( doc.getText(0, doc.getLength()) );

}

// Returns a reader on the HTML data. If 'uri' begins

// with "http:", it's treated as a URL; otherwise,

// it's assumed to be a local filename.

static Reader getReader(String uri)

throws IOException

{

// Retrieve from Internet.

if (uri.startsWith("http:"))

{

URLConnection conn = new URL(uri).openConnection();

return new InputStreamReader(conn.getInputStream());

}

// Retrieve from file.

else

{

return new FileReader(uri);

}

}

}

[1421 byte] By [Rakesh_222a] at [2007-11-26 16:53:16]
# 1
Please post the code using code tags, as it is impossible to read as is.
Djaunla at 2007-7-8 23:20:56 > top of Java-index,Desktop,Core GUI APIs...
# 2
That code simply downloads html code and returns it as a String. You'll need to parse the html. For that, you have many options: http://www.google.com/search?q=Java+HTML+parser
Jasprea at 2007-7-8 23:20:56 > top of Java-index,Desktop,Core GUI APIs...
# 3

import java.io.*;

import java.net.*;

import javax.swing.text.*;

import javax.swing.text.html.*;

class GetHTMLText

{

public static void main(String[] args)

throws Exception

{

EditorKit kit = new HTMLEditorKit();

Document doc = kit.createDefaultDocument();

// The Document class does not yet handle charset's properly.

doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);

// Create a reader on the HTML content.

Reader rd = getReader(args[0]);

// Parse the HTML.

kit.read(rd, doc, 0);

// The HTML text is now stored in the document

System.out.println( doc.getText(0, doc.getLength()) );

}

// Returns a reader on the HTML data. If 'uri' begins

// with "http:", it's treated as a URL; otherwise,

// it's assumed to be a local filename.

static Reader getReader(String uri)

throws IOException

{

// Retrieve from Internet.

if (uri.startsWith("http:"))

{

URLConnection conn = new URL(uri).openConnection();

return new InputStreamReader(conn.getInputStream());

}

// Retrieve from file.

else

{

return new FileReader(uri);

}

}

}

sorry here is the codes again

this one actually returns all the text in a webpage

i need one which return only those texts in a paragraph

Rakesh_222a at 2007-7-8 23:20:56 > top of Java-index,Desktop,Core GUI APIs...