How to convert HTML to plain text in Java?

I want to get the content(text) from html.Although there are several third-party tools could do it,but I want know if there have some simple way?
[166 byte] By [Eastsuna] at [2007-11-26 20:02:02]
# 1

A quick and dirty example below. You can do this using differently.

public class html2text {

public static void main(String args[]){

String text="<html><head><title>test</title></head>\n<body><h1>Heading</h1></body></html>";

int first=0;

int last=0;

while(true){

first=text.indexOf("<");

last=text.indexOf(">");

if(first>-1 && last >-1){

text=text.substring(0, first)+text.substring(last+1, text.length());

}else{

break;

}

}

System.out.println(text);

}

}

AsbjornAarrestada at 2007-7-9 23:00:58 > top of Java-index,Desktop,Deploying...